Re: NSManagedObject awakeFromFetch not sent on secondary thread?
Re: NSManagedObject awakeFromFetch not sent on secondary thread?
- Subject: Re: NSManagedObject awakeFromFetch not sent on secondary thread?
- From: Tom <email@hidden>
- Date: Tue, 16 Mar 2010 11:25:44 +0100
Hi
Sorry, I wasn't explicit enough in my mail - my operation does have it's own
context, and when I fetch against it, awakeFromFetch is not sent, so my
initialization code doesn't get executed. The operation is added to a custom
(i.e. not main one) NSOperationQueue, which does have max concurrency > 1.
Hmm - I thought *every* NSOperation needs it's own managed object context,
even if used in operation queue with max concurrency == 1 as it still gets
executed "concurrently" regarding to main thread?
Anyway I've solved my problem by lazily creating required objects and use a
bit more complicated mechanisms to pass exact instances from main thread to
my operation (this is primarily used for unit testing where I need to inject
non-default objects and I can only do this prior than executing the code).
However I still don't understand why awakeFromFetch is not sent in secondary
thread - I can't find any clue in documentation? Is this a bug or is it a
feature? I'm running on 10.6.2.
Thanks, Tom
On 15 March 2010 20:36, Ben Trumbull <email@hidden> wrote:
>
> Does the secondary thread have its own private NSManagedObjectContext that
> you are using for the fetch, or are you fetching against an
> NSManagedObjectContext that was created on another thread ? If you are
> using an NSOperationQueue with maxConcurrency > 1, then each NSOperation
> will need to allocate, use, and deallocate its own NSManagedObjectContext.
>
> - Ben
>
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden