Re: Core Data load document store without document for QuickLook plugin
Re: Core Data load document store without document for QuickLook plugin
- Subject: Re: Core Data load document store without document for QuickLook plugin
- From: David Sinclair <email@hidden>
- Date: Fri, 21 Dec 2007 13:08:26 -0800
On Dec 21, 2007, at 12:26:18, mmalc crawford wrote:
On Dec 21, 2007, at 12:16 PM, David Sinclair wrote:
Not sure. No non-Apple frameworks. In the app, I link against
Carbon, Cocoa, CoreFoundation, CoreServices, Foundation, AppKit,
ExceptionHandling, SystemConfiguration, AddressBook, CoreData, and
WebKit. The plugin wouldn't use several of those.
Which version of Mac OS X are you targeting?
Leopard.
As a first step, override managedObjectModel:
- (id)managedObjectModel
{
static id sharedModel = nil;
if (sharedModel == nil)
{
NSString *modelPath = [[NSBundle mainBundle]
pathForResource:@"MyDocument" ofType:@"mom"];
NSURL *modelURL = [NSURL fileURLWithPath:modelPath];
sharedModel = [[[NSManagedObjectModel alloc]
initWithContentsOfURL:modelURL] autorelease];
}
return sharedModel;
}
(written in Mail).
After substituting [NSBundle bundleForClass:[self class]] for
[NSBundle mainBundle], that worked.
So based on that clue, I changed my code to:
managedObjectModel = [[NSManagedObjectModel
mergedModelFromBundles:[NSArray arrayWithObject:[NSBundle
bundleForClass:[self class]]]] retain];
And that also worked. The key was that the -mainBundle was /usr/bin
(presumably the QuickLook engine), not the plugin, so using the
correct bundle fixed it.
Thank you!
--
David Sinclair, Dejal Systems, LLC - email@hidden
Dejal blog - http://www.dejal.com/blog/
Cocoa code - http://www.dejal.com/developer/
Now on Twitter - http://twitter.com/dejal/
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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