Objective-c – problem related to NSString

cocoaiphoneobjective c

I have 1 NSString *abc = @"Hardik";
i have NSMutableArray *array;
now i had written [array addobject:abc];

then i'm printing,NSLog(@"array = %@", array);

but i'm getting NULL
why?
I have declared NSMutableArray *array; in a.h file
i had set @property(nonatomic,retain)NSMutableArray *array;
@synthesize array;

and i have synthesize it but getting value NULL
I'm not able to understand it?

Best Answer

You also need to initialise your array:

array = [[NSMutableArray alloc] initWithCapacity:10];

This is pretty fundamental stuff. Have you read the "Learning Objective C Primer" yet?

Related Topic