Skip navigation.
 
mlAllocate memory for object
FROM : Apirak
DATE : Sat Dec 11 10:53:24 2004

Hello,

I try to add two object to myArray by one variable. my source code is
look like this

   NSMutableArray *myArray = [[NSMutableArray alloc] init];
   
   Word *word;
       
   word = [[Word alloc] init];
   [word setWord:@"test"];
   [myArray addObject:word];
   
   word = nil;
   word = [[Word alloc] init];
   [word setWord:@"test2"];
   [myArray addObject:word];
   
   Word *wd = [[myArray objectAtIndex:0] retain];
   NSLog(@"word equal %@", [wd getWord]);
   
   wd = [[myArray objectAtIndex:1] retain];
   NSLog(@"word equal %@", [wd getWord]);

the result is

word equal test2
word equal test2

but It should be

word equal test
word equal test2

I am java developer, it very hard to deal with vector :(

Apirak Panatkool

e-mail: <email_removed>
phone: 01-4033320

Related mailsAuthorDate
mlAllocate memory for object Apirak Dec 11, 10:53
mlRe: Allocate memory for object Jonathon Mah Dec 11, 15:17
mlRe: Allocate memory for object Jonathan Jackel Dec 11, 18:34
mlRe: Allocate memory for object Andrew Merenbach Dec 12, 10:32