Closed kenmaz closed 8 years ago
[NSManagedObjectContext MR_context]
creates a new NSManagedObjectContext
with MR_rootSavingContext
as it's parent, not MR_defaultContext
as the parent.
Oh..Sorry, my working copy was version 2.2. it's old version. Actually, it was fixed already in version 2.3.
Thanks you for helping me.
I aften see example code to fetch an object in background. Like a following.
But, I think this code is not recommended. Because MagicalRecord's
MR_context
creates local context withMR_defaultContext
as parent context.MR_defaultContext
isNSMainQueueConcurrencyType
context. it works on main thread.So the above code run through the main thread when fetch some data. It cause a little blocking in main thread. It is not good for fetching performance.
I think the following code is good.
Because this code doesn't run in main thread. Both
MR_rootSavingContext
and local context areNSPrivateQueueConcurrencyType
. It run in background perfectly.Moreover , if some object is changed in main thread, Maybe the first code is affected that changes accidentally.
The first code's pattern is very elegant but not good performance and un-safe. So I think
MR_context
should useMR_rootSavingContext
as parent context like the second code.Is my idea good or bad ?
Thanks.