Hi,
How can I add the numbers in an NSArray?
What I wan to do is add the numbers in an NSArray and log the result.
Here I'm printing the values of the NSArray but I don't know how to add them together.
Thanks
How can I add the numbers in an NSArray?
What I wan to do is add the numbers in an NSArray and log the result.
Here I'm printing the values of the NSArray but I don't know how to add them together.
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++)
{
NSLog(@"%@", [numbers objectAtIndex:i]);
}
Thanks