Jeeter
Jeeter

Reputation: 6085

NSMutableArray integer storage

I am trying to store numbers inside the NSMutableArray, and have wrapped them like so:

-(IBAction)opUp:(id)sender{
    opBool = YES;
    opNum = [sender tag];
    [numArray addObject:[NSNumber numberWithLong:number2]];
    [opArray addObject:[NSNumber numberWithInt:opNum]];
    number1 = 0;
    number2 = 0;
    opNum = 0;
    NSLog(@"Operand %i", opNum);
    NSLog(@"%i, %i", numArray.count, opArray.count);
 }

But when I call them later using this:

    final2 = [numArray objectAtIndex:i];
    operthing = [opArray objectAtIndex:i];

I get this error message:

operthing equals 111526320

'operthing' is not supposed to go beyond 20. Can someone help me with this? Thanks.

Upvotes: 0

Views: 188

Answers (1)

Jesse Gumpo
Jesse Gumpo

Reputation: 4787

operthing = [[opArray objectAtIndex:i] intValue];

Upvotes: 2

Related Questions