mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 20:00:30 +01:00
Returning created records from synchronous transactions #51
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 @jamesbebbington on GitHub (Apr 22, 2016).
Hey John,
I may be being a bit stupid here but, from having read the README it's not clear to me how I should be returning
NSManagedObjects from synchronous transactions. I see CoreStore providesfetchExistingbut I'm not sure how to use it in this example:Thanks.
@JohnEstropia commented on GitHub (Apr 23, 2016):
You'll need to assign it to an outer variable.
The risk of deadlock with synchronous transactions are kind of worrying though. I recommend you use asynchronous transactions instead, or to call
beginSynchronous()from a background thread.Otherwise, if you are just creating a new object and you don't need to fetch from within the transaction, it might actually be safe and performant to not rely on the transaction queueing mechanism.
@jamesbebbington commented on GitHub (Apr 25, 2016):
Thanks John, that's what I was looking for. And thanks for the warning about deadlocks, I'll try and migrate over to asynchronous transactions.