hi i am new iphone programmer i want to know that can we create array of integer,array of strings....etc seperatly like c++ if yes then how.... i have read about the example given on this site but that is c style of array.... please reply
2 Answers
NSArray is the standard array class in Cocoa/Cocoa Touch. It can contain objects, but not primitives.
You can store integers in an array by wrapping them with an NSNumber object like so:
NSNumber *myInt = [NSNumber numberWithInt:1];
Then you can store it in an array like so:
NSArray *myArray = [NSArray arrayWithObject:myInt];
1 Comment
Ranjeet Sajwan
i tried this one but problem is that i want to store man values in it but it does not supporting
NSArray *arr = [NSArray arrayWithObjects:@"a", @"b", @"c", nil];
NSArray *arr = [NSArray arrayWithObjects:[NSNumber numberWithInteger:1]
, [NSNumber numberWithInteger:2]
, [NSNumber numberWithInteger:3]
, nil];
Here's a reference.