raghul
raghul

Reputation: 1048

CoreData Relationship Contents not persisting

enter image description here

i have the following relationship, the book entity is working fine. But when i try to provide the relationship and add it to the wishlist the value is not persisting, it is only available temporarily.

here is the code how i add the relationship

WishListBooks *wishList = [NSEntityDescription insertNewObjectForEntityForName:@"WishListBooks" inManagedObjectContext:[self getCoreDataContext]];

[wishList addContainsObject:self.bookEntity];


NSError *saveError;

if (![[self getCoreDataContext] save:&saveError]) {
    NSLog(@"Saving changes to book book two failed: %@", saveError);
} else
{
    NSLog(@"Data Saved onto Coredata");
}

but when i print the logs i get.

<_PFArray 0x79f31bf0>(
<WishListBooks: 0x79fc1730> (entity: WishListBooks; id: 0x79f9a3e0 <x-coredata://150C6D01-71AB-4324-B5F4-9D553630C985/WishListBooks/p1> ; data: <fault>),
<WishListBooks: 0x79fbe6f0> (entity: WishListBooks; id: 0x79f2a390 <x-coredata://150C6D01-71AB-4324-B5F4-9D553630C985/WishListBooks/p2> ; data: <fault>),
<WishListBooks: 0x79fb33d0> (entity: WishListBooks; id: 0x79fb4250 <x-coredata://150C6D01-71AB-4324-B5F4-9D553630C985/WishListBooks/p3> ; data: <fault>),
<WishListBooks: 0x79f34cd0> (entity: WishListBooks; id: 0x79fc5520 <x-coredata://150C6D01-71AB-4324-B5F4-9D553630C985/WishListBooks/p4> ; data: <fault>),
<WishListBooks: 0x79fb73e0> (entity: WishListBooks; id: 0x79fc5530 <x-coredata://150C6D01-71AB-4324-B5F4-9D553630C985/WishListBooks/p5> ; data: <fault>),
<WishListBooks: 0x79f35ae0> (entity: WishListBooks; id: 0x79fb1e50 <x-coredata://150C6D01-71AB-4324-B5F4-9D553630C985/WishListBooks/p6> ; data: <fault>)
)

Upvotes: 0

Views: 93

Answers (1)

Tom Harrington
Tom Harrington

Reputation: 70946

What you're seeing are Core Data faults. These are not errors and they do not indicate that the relationship data was not saved. When Core Data loads data from a persistent store, it loads it as a fault, which means that it's a placeholder object that has not loaded its attribute values. If you try to use those attribute values, they're loaded on demand. This is entirely normal-- there's actually no sign of anything being wrong in that message in your question.

Upvotes: 1

Related Questions