Search code examples
uinavigationcontrollerpopupstackcrash

Crashed when pop out of a UINavigationController


I have several viewControllers controlled by a navigation controller.

For example, viewController A and viewController B can both push viewController C into the navigation stack and ask C to do some saving (actually means the same to C).

in the saving method of C, the last line of code is

[self.navigationController popViewControllerAnimated:YES];

But problem is,

If I push to C from A, after I save something and pop back to A, things goes well.

But if I push C to from B, after I do the same thing and pop back to B, app crashes,

with my debugging, I found that app crashed not in C's code,

but after B's viewWillAppear method, here I mean after, B correctly runs all of the codes in viewWillAppear,

but then crashes somewhere I don't know how to trace to.

and the Error is very strange to me:

2012-02-13 00:29:30.975 EasyWallet[43116:707] *** Terminating app due to uncaught exception     
'NSInvalidArgumentException', reason: '*** -[__NSCFConstantString stringByAppendingString:]: nil argument'
*** First throw call stack:
(0x344268bf 0x346761e5 0x344267b9 0x344267db 0x35d72121 0x2ce7b 0x2ba75 0x3782f9cb 0x3782eaa9    
0x3782e233 0x377d2d4b 0x3438522b 0x34f16381 0x34f15f99 0x34f1a11b 0x34f19e57 0x34f11d85    
0x343fab4b 0x343f8d87 0x343f90e1 0x3437c4dd 0x3437c3a5 0x30c00fcd 0x377fd743 0x2179 0x2138)
terminate called throwing an exception(gdb) 

I just don't know how to fix it.


Solution

  • While dealing with number of viewControllers and views, it happens that frequent crashes occurs. I also had same problem when not using ARC. At that time i found the best way out is using following link to get into exact crash. The only thing is you need to carefully analyzed the result at console and should judge it better way...

    http://www.cocoadev.com/DebuggingAutorelease.html