views:

1212

answers:

2

How can I create an NSArray with values prepopulated.

That is to say:

NSArray *name=[NSArray alloc];

// insert these values: raju, biju.ramu

Thanks and regards from raju..

+11  A: 

Use the NSArray initWithObjects method, remembering to put nil in as the last value:

NSArray *names = [[NSArray alloc] initWithObjects:@"raju", @"biju", @"ramu", nil];
nevan
+7  A: 

If you need to modify an existing array, You must use NSMutableArray

NSMutableArray *name=[[NSMutableArray alloc]init]; 
[name addObject: @"raju"];
[name addObject: @"biju"];
oxigen
If he indeed wants to modify an existing array, you should use this as declaration;NSArray *name_array = [[NSArray alloc] init];// array stuffNSMutableArray *names = [[NSMutableArray alloc] initWithArray:name_array];[names addObject: @"raju"];[names addObject: @"biju"];
MiRAGe
yes, that's right.
Roger Nolan