On Tue, Oct 12, 2010 at 1:14 PM, Michael Link <ml...@fractal.net> 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 (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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com