2012-07-09 46 views
0

我想存儲的NSMutableArray中間的數字,幷包裹其中,像這樣:NSMutableArray的整數存儲

-(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); 
} 

但是,當我打電話給他們在以後通過此:

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

我得到這個錯誤消息:

operthing等於111526320

'operthing'不應該超過20. 有人可以幫助我嗎? 謝謝。

+0

你如何得到operthing的價值?您是否使用了與您調用的'numberWith'方法相對應的'value'方法? – 2012-07-09 21:20:40

+1

請顯示您用來創建'opNum'並檢查'operthing'的代碼。 – 2012-07-09 21:21:11

+1

operthing = [[opArray objectAtIndex:i] intValue] – 2012-07-09 21:24:00

回答

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