objective c - Crashing iOS App with [Class retain]: message sent to deallocated instance -
i building app , i'm quite noob, please forgive lack of information!
i'm able crash app in set of steps reproduce, sometimes. when crashes, on main.m file with:
i've set exception breakpoint "throw" , separately "catch" , doesn't pick particular line of code on crash occurs.
how find out causing issue, or line(s) of code?
i testing on iphone 5s , 6 plus , crashes on both.
update
i have been doing testing , workflow of app.
i have uitableviewcontroller
(called more tab). click on uiviewcontroller
(called themes) , there's button there. click on button , calls uialertview
. click on non-cancel button , calls uiviewcontroller
(called iap). there's uibutton
price , uibarbuttonitem
called cancel. if click cancel, dismisses iap uiviewcontroller , goes themes uiviewcontroller.
the uibutton
on iapviewcontroller dynamically calls price uiviewcontroller
called unlimited entries.
i'm noticing crash if click on cancel button before price has loaded on uibutton
.
with zombies, crash console shows:
2015-04-29 10:21:33.775 -[unliimitedentriespurchase retain]: message sent deallocated instance 0x174e4f4b0
in viewdidload
of iapviewcontroller
, have:
[self.unlimitedentriespurchase validateproductidentifiers];
i have property created: @property (nonatomic, strong) unliimitedentriespurchase *unlimitedentriespurchase;
, i'm thinking issue.
i hope makes sense , helps determine issue be.
it's rare case user come iap , click cancel button (to dismiss iapviewcontroller
) before price loads on uibutton
. however, it's i'd fix rather ship obvious issue.
update 2
in iapviewcontroller, have custom setter:
- (unliimitedentriespurchase *)unlimitedentriespurchase { if (!_unlimitedentriespurchase) { _unlimitedentriespurchase = [[unliimitedentriespurchase alloc] init]; _unlimitedentriespurchase.delegate = self; } return _unlimitedentriespurchase; }
with setting alloc , init in appdelegate, if statement not getting true here , custom delegate never gets set.
the probable cause firing action deallocated object, have that:
product ---> profile ---> zombies (in instruments)
and check in instrument tool object crashing.
you can reallocate object in place, example show how reallocate in appdelegate, first have add in appdelegate.h
@property (nonatomic, strong) unliimitedentriespurchase *unlimitedentriespurchase; + (appdelegate*) shareddelegate;
and in appdelegate.m
+ (appdelegate*) shareddelegate { return (appdelegate*)[uiapplication sharedapplication].delegate; }
the in view controller have import appdelegate.h , allocate object that
[appdelegate shareddelegate].unlimitedentriespurchase = self.unlimitedentriespurchase;
after can fire unlimitedentriespurchase methods becouse never going deallocated, if have problem can fire [appdelegate shareddelegate].unlimitedentriespurchase
Comments
Post a Comment