NSMutableString appendString generates SIGABRT Error

前端 未结 1 2029
故里飘歌
故里飘歌 2021-01-26 03:54

New here (this forum and Xcode in general), so bear with me.

I\'ve spent multiple hours off and on over the last severals days trying to track down what exactly that I\'

相关标签:
1条回答
  • 2021-01-26 04:25

    * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM appendString:]: unrecognized selector sent to instance 0x4e3d300' *

    This indicates that you are calling appendString: an instance of some kind of NSArray, which obviously won't work.

    Assuming that [self.display appendString:info]; is the actual source of the exception, then it is happening because self.display has likely been over-released and, coincidentally, an NSArray instance was allocated at the same place in memory.

    You could use zombie detection to debug this.

    Alternatively, you might be corrupting memory somewhere. Or, maybe, there is another assignment to display.

    In any case, whenever you have a crash, there will be a backtrace. Please post it. There is the off chance that the crash is happening somewhere else.


    5 Calculator 0x0000273b -[CalculatorViewController digitPressed:] + 113
    

    Show the source to your digitPressed: method.


    self.display = [[NSMutableString alloc] init];  
    

    That is a memory leak; it'll be retained twice. Just do self.display = [NSMutableString string]; and self.display = nil; (in your viewDidUnload).

    But that isn't the source of your problem; something is resetting the display variable or it is being over-released. Show all uses of display.

    0 讨论(0)
提交回复
热议问题