0

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.

4
  • How are you getting operthing's value? Are you using the value method corresponding with the numberWith method you called? Commented Jul 9, 2012 at 21:20
  • 1
    Please show the code you're using to create opNum and to inspect operthing. Commented Jul 9, 2012 at 21:21
  • 1
    operthing = [[opArray objectAtIndex:i] intValue] Commented Jul 9, 2012 at 21:24
  • @JesseGumpo : post it as an answer! Commented Jul 9, 2012 at 21:27

1 Answer 1

2
operthing = [[opArray objectAtIndex:i] intValue];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.