Monday, 9 January 2012

How to add and retrieve NSMutableArray value dynamically

NSMutableArray parent class is NSArray


 //Add values dynamically

 NSMutableArray* arr_country = [[NSMutableArray alloc]init];
 [arr_country addObject:@"INDIA"];
 [arr_country addObject:@"RUSSIA"];

 //retrieve array value

id maybeNSString = [arr_country objectAtIndex:(NSUInteger)0]; //return value of the zero th position

//get array count
NSInteger arr_count  = arr_country.count;