ios - dismissViewControllerAnimated sends message to zombie object -
i have 2 uiviewcontrollers, vc1 , vc2. vc1 has button invokes triggered modal segue vc2. segue defined in storyboard. in vc2, user can return vc1 using pan gesture executes line of code:
[self.presentingviewcontroller dismissviewcontrolleranimated:yes completion:nil]; this code has worked long time. however, of sudden when line runs, app crashes. enabled zombie objects , can see error:
-[vc2 retain]: message sent deallocated instance 0x7f843a81e200
i've run zombie profiler , here results:
uiclassswapper initwithcoder seems app crashes, , there appears on retained object there, can't further. when set exception breakpoint, assembly code, , isn't of apparent help.
so, there couple of questions here. first doing wrong in how presenting , dismissing view controller? after that, don't know how crack event history figure out how handle zombie object.
any appreciated. thank you!
it seems use arc project. please provide more code:
1. how initialize presentingviewcontroller property (and declare). (nonatomic,strong)?
2. how put viewcontroller screen. kind of modal view controller etc?
-- added after comment.
arc based project decides automatically if object needed or not , removes stack automatically. so, 1 useful recipe avoid problem add nsnotification observer , post there notifications time after time. keep view controller in stack , avoid automatic release.
solution - check if controller still in stack:
if (!self.presentingviewcontroller) [[thecontroller alloc] init]; the third 1 - use object declare vc1 , vc2 class variables, , present them modal view controller when needed. in case, object , variables kept untouched long of vcs presented.
in case, exception happens because arc considers vc not needed anymore , releases atomatically.

Comments
Post a Comment