Passing NSManagedObjects Between ViewControllers - Random Bad Access Errors

Is NSManagedObjects between ViewControllers a bad idea? I have an iPad app and I seem to have encountered random malfunctions and sigbart errors.

These NSManageObjects come from CoreData, and it seems to me that sometimes they just lose memory and cause this. I was hoping to simply transfer them from controller to controller so as not to fetch on each view manager.

+3
source share
3 answers

, . , (), NSManagedObjects VeiwControllers .

, ViewController refcount . .

, , ViewControllers,

@property (nonatomic, retain) NSManagedObject *yourObject;

, , :

self.yourObject = ...;

... :

otherViewController.yourObject = ...;

/ .

+6

, . . , , . NSManagedObjects , , ( , ), .

+2

, NSManagedObject, . - AppDelegate ObjectContext,

[[[UIApplication sharedApplication] delegate] managedObjectContext];

, retain, .

+1

Source: https://habr.com/ru/post/1778013/


All Articles