iphone - passing NSManagedObjects between ViewControllers - random bad access errors -
is passing nsmanagedobjects between viewcontrollers bad idea? have ipad app , seem run random bad access crashes , sigbart errors.
these nsmanageobjects coming coredata , wonder if drop out of memory , cause this. hoping pass them controller controller avoid doing fetch on every viewcontroller.
sounds it's matter of bad object memory allocation practices. long you're not multithreading app , there 1 managedobjectcontext (typical), can pass these nsmanagedobjects between veiwcontrollers no problem.
what's happening you're passing reference 1 viewcontroller without incrementing it's refcount retain message. can dicey.
what i'd recommend having retain property on viewcontrollers, like
@property (nonatomic, retain) nsmanagedobject *yourobject;
then, when managed object, keep this:
self.yourobject = ...;
... , when want pass view controller:
otherviewcontroller.yourobject = ...;
and take care of setting retain/release you.
Comments
Post a Comment