Hi,
I'm trying to display the values from an NSArray and for some reason I'm only getting the last value.
In this code I have to NSNumbers in an NSArray but when I try to out put their values I only get the value from the last object in the array.
Any idea what am I doing wrong?
[/CODE]
Out putting the values to the console is not a problem
I'm trying to display the values from an NSArray and for some reason I'm only getting the last value.
In this code I have to NSNumbers in an NSArray but when I try to out put their values I only get the value from the last object in the array.
Any idea what am I doing wrong?
Code:
[CODE] NSNumber *myInt;
myInt = [NSNumber numberWithInt:5];
NSNumber *myInt2;
myInt2 = [NSNumber numberWithInt:10];
NSArray *numbers = [NSArray arrayWithObjects:myInt, myInt2, nil];
for(int i = 0; i < [numbers count]; i++)
{
int nums = [[numbers objectAtIndex:i] intValue];
self.display.text = [NSString stringWithFormat:@"%i \n", nums];
}
Out putting the values to the console is not a problem
Code:
NSLog(@"%@ \n", [numbers objectAtIndex:i]);
Last edited: