How can you make this work?
numbers = [[NSMutableArray alloc] initWithObjects: ({int x = 0; while (x <= 60 ) { return x; x++; } })];
Thanks :)
How can you make this work?
numbers = [[NSMutableArray alloc] initWithObjects: ({int x = 0; while (x <= 60 ) { return x; x++; } })];
Thanks :)
NSMutableArray * array = [[NSMutableArray alloc] init];
for (int i = 0; i <= 60; ++i) {
[array addObject:[NSNumber numberWithInt:i]];
}
int myStrangeNumberOfItems = 61;
NSMutableArray * numbers = [[NSMutableArray alloc] initWithCapacity: myStrangeNumberOfItems];
for (int i = 0; i < myStrangeNumberOfItems; i++) {
[numbers addObject:[NSNumber numberWithInt:i]];
}
First, an NSArray can only hold objects, not primitives. You can add the objects within a for loop like so.
NSMutableAray * numbers = [[NSMutableArray alloc] init];
for (int x = 0; x <= 60; x++)
[numbers addObject:[NSNumber numberForInt:x]];