I am new to iphone development.I want a Nsmutable array to hold numbers from 1 to 100.How i can do it.how can i implement in a for loop.Is there any other way to hold numbers in array in iphone.Please help me out.Thanks.
I am a newbie, can u give more code,of how u save the values in a array.Thanks.
Warrior
2010-04-10 15:08:29
+3
A:
You can only add NSObject subclasses in Cocoa containers. In your case, you will have to wrap your integers in NSNumber objects:
NSMutableArray *array = [NSMutableArray array];
for( int i = 0; i < 100; ++i )
{
[array addObject:[NSNumber numberWithInt:i]];
}
To extract the values:
int firstValue = [[array objectAtIndex:0] intValue];
Martin Cote
2010-04-10 15:11:23