On 2012-12-01, at 11:42 AM, Mike Abdullah <cocoa...@mikeabdullah.net> wrote:
>>>>> One way to look at it is that NSPersistentDocument pretty much painted 
>>>>> itself into a corner from day 1, and it's too messy for Apple to untangle 
>>>>> that.
>>>> 
>>>> Can you elaborate?
>>> 
>>> Well it makes the assumptions that your document:
>>> 
>>> - is comprised of a single Core Data store
>>> - has a single managed object context
>> 
>> This definitely limits your options. But, is it necessary to support file 
>> wrappers and iCloud? (Just trying to educate myself about how documents 
>> work.)
> 
> I don't understand your question here. Are you asking if my list of 
> assumptions are necessary conditions for iCloud and file wrapper support?

Yes, that was basically the question. For example, what if you were just using 
file wrappers to store images outside the persistent store.

>>> - works entirely on the main thread
>> This one is already opt-in for both opening and saving, so fragility 
>> shouldn't be an issue to upgrading the class.
>> 
>> [Aside: As far as I know you *can* actually open an NSPersistentDocument 
>> asynchronously. At least I haven't seen anything that says you can't, and it 
>> seems to work on every system I've tried it on.]
> 
> Well you would appear to be breaking Core Data's threading contract by doing 
> so. In theory, MOCs know the thread they were created on. So by creating the 
> document on a background thread, you are also creating the MOC on that thread 
> and giving it the wrong idea about the thread it will be used on.

NSPersistentDocument always creates a MOC of type NSMainQueueConcurrencyType, 
even if it is created on a background thread. So as long as things don't go 
wrong during document opening, everything will be the same as a document opened 
on the main thread forever after.

I believe, the window controller and view objects are always created on the 
main thread after the MOC has been initialized, so there won't be any 
contention with trying to access the MOC from different threads at the same 
time.

This is all identical on 10.6 and 10.7+.

> 
> On 10.7+ you can of course tell the context at creation time it's for the 
> main thread, but I'd be a little surprised if NSPersistentDocument is doing 
> that.
> 
> I also covered the topic fairly recently: 
> http://www.mikeabdullah.net/concurrently-open-core-data-docs.html
> 


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to