• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSPersistentDocument and canConcurrentlyReadDocumentsOfType
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >NSPersistentDocument and canConcurrentlyReadDocumentsOfType (From: Michael Link <email@hidden>)

  • Prev by Date: NSPersistentDocument and canConcurrentlyReadDocumentsOfType
  • Next by Date: Re: The dreaded "UITableView won't refresh" problem.
  • Previous by thread: NSPersistentDocument and canConcurrentlyReadDocumentsOfType
  • Next by thread: Cocoaheads Lake Forest (92630) meeting this Wednesday from 7-9 pm - Open Mic night, charge the stage and crowd surf!
  • Index(es):
    • Date
    • Thread