Re: NSPersistentDocument and canConcurrentlyReadDocumentsOfType
Re: NSPersistentDocument and canConcurrentlyReadDocumentsOfType
- Subject: Re: NSPersistentDocument and canConcurrentlyReadDocumentsOfType
- From: Kyle Sluder <email@hidden>
- Date: Tue, 12 Oct 2010 13:23:03 -0700
On Tue, Oct 12, 2010 at 1:14 PM, Michael Link <email@hidden> wrote:
> In the documentation for NSPersistentDocument's method -managedObjectModel it says the following addition in a subclass can be used to improve efficiency if all the documents share the same model.
>
>> - (id)managedObjectModel {
>> static id sharedModel = nil;
>> if (sharedModel == nil) {
>> sharedModel = [[super managedObjectModel] retain];
>> }
>> return sharedModel;
>> }
>
> If the app is running on 10.6 and returns YES for canConcurrentlyReadDocumentsOfType I'm assuming some sort of synchronization would be necessary here?
Sure, you could do this:
- (id)managedObjectModel {
static id sharedModel;
static dispatch_once_t once;
dispatch_once(&once, ^{ sharedModel = [[super managedObjectModel] retain]; });
return sharedModel;
}
--Kyle Sluder
_______________________________________________
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