Reputation: 650
I have a core data model like so:
User
- objectId
- access (transformable - array of "User_Access")
CustomObject
- objectId
- name
- etc
User_Access
- customObject
The objects save correctly and the transformable access array properly is filled, but on the second use of the app, the "access" array is an array of unfilled objects:
"<User_Access: 0x6060001746e0> (entity: <null>; id: (null); data: <fault>)"
I'm using a fetch request like so:
NSFetchRequest *fetch = [NSFetchRequest fetchRequestWithEntityName:@"User"];
[fetch setReturnsObjectsAsFaults:NO];
[fetch setIncludesSubentities:YES];
[fetch setIncludesSubentities:YES];
NSArray *test = [[SPModel objectContext] executeFetchRequest:fetch error:nil];
if (test.count == 0) {
return nil;
}
User *user = (User *)test.firstObject;
The fetch request fetches the properties of the user object perfectly, but the transformable "access" array is unpopulated.
Upvotes: 0
Views: 25
Reputation: 650
Solved!
Instead of using transformables to store an array of core data objects, use a relationship and set the destination to the custom object class, and change the type from To One
to To Many
.
This will require you change your property in your header file to an NSSet
instead of an NSArray
.
Upvotes: 1