我在運行時崩潰時,彈出了最後一個元素從NSMuttable array.I獲取所有元素正常,但是當我獲取最後一個元素時它會給出錯誤。無法在運行時從nsarray崩潰中獲取變量
-(id)popOperand{
id operandObject = [self.operandStack lastObject];
if(operandObject) [self.operandStack removeLastObject];
return operandObject;
}
對於例如: - 如果在我的堆棧我有 「8」(及其NSNumber的對象) 「+」(其的NSString對象)2(其的NSNumber對象)。
NSNumber *rightOperand = [self popOperand];
NSString *operation = [self popOperand];
NSNumber *leftOperand = [self popOperand];//when i acess 8 it shows empty array other element is getting fine;
我的問題是爲什麼我無法獲得最後一個對象,而這個功能對其他元素工作正常。 編輯:在運行時彈出2後它顯示堆棧(8 +),但在我poped +它顯示堆棧()empty.But「leftOperand」沒有獲得價值。我沒有使用ARC。
請精心準備。 謝謝。
什麼錯誤.... – Peres
@JackyBoy EXBadAcess – iosman
後的堆棧跟蹤? – trojanfoe