Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 02-17-2010, 08:50 PM   #2 (permalink)
yaxomoxay
Registered Member
 
Join Date: Feb 2010
Posts: 2
yaxomoxay is on a distinguished road
Default

OK, I reply to myself. I just found a similar example and this is the result :

Code:
#import <Foundation/Foundation.h>

@interface Person : NSObject
  {
    NSString *person;
  }
  -(void) SetPersonName : (NSString*) name;
  //-(NSString) GetPersonName;
@end

@implementation Person
  -(void) SetPersonName : (NSString*) name;
    {
      [name retain];
      //[person release]
      person = name;
    }  
@end

int main (int argc, const char * argv[])
  {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    Person * testperson;
    testperson = [Person alloc];
    testperson = [testperson init];

    NSString * nametogive = @"Louis Armstrong";
    [testperson SetPersonName : nametogive];
    [pool drain];
    return 0;
  }
Somehow I don't get any error, I have to verify if it actually prints "Louis Armstrong". I'll let you know. One question. I don't get this passage:
Code:
-(void) SetPersonName : (NSString*) name;
    {
      [name retain];
      //[person release]
      person = name;
    }
What is the "retain" doing ?

Thanks
yaxomoxay is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,486
Threads: 94,041
Posts: 402,630
Top Poster: BrianSlick (7,978)
Welcome to our newest member, hughricotta
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:06 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.