Re: NSObjectController and Core Data
Re: NSObjectController and Core Data
- Subject: Re: NSObjectController and Core Data
- From: "Kevin" <email@hidden>
- Date: Thu, 22 Feb 2007 16:24:18 +0000
- Importance: Normal
- Sensitivity: Normal
Here it is.
The following code is from applicationDidFinishLaunching:. in my application delegate. For the sake of simplicity, there is only one entity in my model of which a single instance is created if it doesn't exist already.
controller = [[NSObjectController alloc] initWithContent:nil];
[controller setEntityName:@"MyEntity"];
[controller setManagedObjectContext:[self managedObjectContext]];
[controller setFetchPredicate:[NSPredicate predicateWithFormat:@"id == 1"]];
I execute a fetch request manually in both cases (nib and programmatic creation) as follows. i.e. "Automatically prepares content" is unchecked when the controller is created in nib.
NSError *error;
[controller fetchWithRequest:nil merge:NO error:&error];
Thanks for helping out.
Kevin
Sent via BlackBerry from Cingular Wireless
-----Original Message-----
From: "Sean McBride" <email@hidden>
Date: Thu, 22 Feb 2007 10:52:50
To:Kevin <email@hidden>, "Scott Anguish" <email@hidden>
Cc:<email@hidden>
Subject: Re: NSObjectController and Core Data
On 2007-02-22 08:03, Kevin said:
>Console log when NSObjectController created in nib:
>
>2007-02-22 07:37:44.006 ObjectController[233] object
>controller:<NSObjectController: 0x358940>[entity: MyEntity] <---
>Entity Mode
>
>Console log when NSObjectController created programmatically:
>
>2007-02-22 07:36:35.619 ObjectController[186] object
>controller:<NSObjectController: 0x32cd30>[object class:
>NSMutableDictionary] <--- Object Mode
>
>Even though the object controller is created in identical fashion in
>both nib file and programmatically, the one created programmatically
>seems to be stuck in "Object" mode. I've called setEntityName:, which
Could you show us the code that creates it programatically?
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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