mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-14 07:33:28 +01:00
Data not saving to entities #141
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @martheli on GitHub (May 25, 2017).
My code runs without error but when I try to print out the entity I receive the following print:
My code is simple and pretty much right from the readme but it looks like nothing it being added.
@JohnEstropia commented on GitHub (May 25, 2017):
Did you already add a store using
addStorage()?(See the Setting-up section on the README file)
@martheli commented on GitHub (May 25, 2017):
Yes I have this above:
@JohnEstropia commented on GitHub (May 25, 2017):
@martheli Sorry, I just realized you were fetching the object right after calling an asynchronous transaction.
perform(asynchronous:...)executes on a background thread, so the object will not be created yet right after the call. You can try fetching inside thecompletionclosure instead:@martheli commented on GitHub (May 26, 2017):
I moved it inside the completion and the output is the same; no new values.
@JohnEstropia commented on GitHub (May 26, 2017):
@martheli Can you show your console log?
@martheli commented on GitHub (May 26, 2017):
Output is:
[<Person: 0x600000281680> (entity: Person; id: 0xd000000000040000 <x-coredata://091EEDA4-1652-4D5B-AEA0-110672DEBB1A/Person/p1> ; data: <fault>)]@JohnEstropia commented on GitHub (May 26, 2017):
That looks like the array contents and the Person objects is in it, so I think there is no problem. You can try to print the person's name and job:
@martheli commented on GitHub (May 26, 2017):
If people is an array, why can't I just print out the array like "print(people)" to list all the values stored in the entity?
@JohnEstropia commented on GitHub (May 26, 2017):
Because Core Data has something called faulting.
Basically all fetched objects's values would only be loaded in memory after the first value is accessed. You can see this behavior if you do this:
You'll notice the last
printwill print the values becausenamewas accessed on the secondprint