Re: Saving extra data using Core Data
Re: Saving extra data using Core Data
- Subject: Re: Saving extra data using Core Data
- From: Andrew Merenbach <email@hidden>
- Date: Sun, 12 Feb 2006 12:49:23 -0800
Thanks for the response, Chris.
These data don't seem to fit in well with the other data. The other
data are a list of entries in an outline view. These data involve a
text field that takes a number, and an NSSegmentedControl, that
affect the manipulation of the items in the list.)
I think that I'm already doing the Right Thing, then, just in the
Wrong Way.
I have the following code in my NSPersistentDocument class' -
initWithType: (so as to save me the trouble of seeing whether it
exists already or not).
NSEntityDescription *settingsDesc = [NSEntityDescription
insertNewObjectForEntityForName:@"Settings" inManagedObjectContext:
[self managedObjectContext]];
settingsDesc is an NSEntityDescription.
In my -makeWindowControllers I fetch (per Apple's sample code) and
then use addObject: on my NSObjectController.
This is probably not the right place for it, but I'm not sure where
else to put it.
The object controller is new in my experimentation, and when I fetch
settingsDesc after a reload it shows up, but with its data as fault.
- Is the object controller necessary here?
- Is there some reason that the data comes up as fault on reload with
fetch, even without the object controller?
Cheers,
Andrew
On Feb 12, 2006, at 12:12 PM, Chris Hanson wrote:
On Feb 12, 2006, at 11:58 AM, Andrew Merenbach wrote:
I have a program that makes use of Core Data. I would like to
save the state the contents of a text field and a couple of other
controls. What's the best way to go about this, since I can't
encode (can I?) manually? (I tried using an NSObjectController
with a special 'Settings' entity as its contents, and it shows up
on reload when fetched, but its data comes up as fault.)
My question in response is: What does this information represent,
and why isn't that also part of the data model used for your
documents or application?
Just represent the additional information you want to save as an
entity in your data model, create an instance of it in your
document, and use that instance to store the information. You can
locate it via a fetch request, and create and insert it if it's not
present already.
-- Chris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden