If you suspect the objects have already been fetched by someone
else (or yourself previously), use -objectWithID: or -
objectRegisteredForID: instead of -executeFetchRequest:
That's right, but here is the test case I am thinking about :
I have two threads A and B, each one owning their own managed object
context Ma and Mb
thread A computes objects o1, o2, o3, ..., [save], o7, o8
thread B computes objects o11, o7
Since o7 has not been saved in thread A, it has a temporary objectID.
So, I cannot fetch it in Mb, neither with executeFetchRequest, nor
objectWithID.
Is there a solution in this case ?
The save-then-notify-others idiom works quite well with multiple
threads in Core Data.
I think it would be too expensive to call save: for each object,
because it is many of small objects.
So, yes, I could recompute o7 in thread B, but it is not optimal. If
save occurs every two minutes, this may be 2 minutes of computation
lost.
Regards,
Pierre Chatelier
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com