A bit of background:
I am trying to store a large amount of data in a local database, and I want to do this as efficiently as possible.
Scenario:
There are many objects that are interconnected, for example, the address is associated with such a contact:
address ↔ contact
To manage relationships, I wrote a method in each subclass of NSManagedObject, the following is a snippet of code:
- (void)manageRelationships
{
@autoreleasepool {
LocalDBManager *localDBManager = [[LocalDBManager alloc] init];
NSPredicate *addressIdPredicate = [NSPredicate predicateWithFormat:@"%K == %@",ADDRESSID,self.addressid];
NSSet *retrievedAddresses = [localDBManager retrieveManagedObjectsForEntity:ADDR_ENTITY withPredicate:addressIdPredicate asFault:YES withPropertyValues:NO error:nil];
self.addresses = retrievedAddresses;
}
}
Point to consider:
Since there can be multiple relationships for an object, I know that memory consumption will increase when I compare relationships.
Question:
I want to return the object to fault, without losing any changes, after matching the relationship.
Apple , refreshObject: mergeChanges:. manageRelationships:
[[self managedObjectContext] refreshObject:self mergeChanges:YES];
, -
, , , , ? , NSManagedObjectContext
.