a few Core Data questions: Predicates and document based app
a few Core Data questions: Predicates and document based app
- Subject: a few Core Data questions: Predicates and document based app
- From: Michael B Johnson <email@hidden>
- Date: Thu, 18 Dec 2008 10:47:34 -0800
Getting back into Core Data over the holidays, and I've got a few
questions. First, the easy one:
I have an entity (let's called it MyThing) that has an optional
parentThing relationship. I'm interested in MyThings that either
don't have their parent set, ("parentThing == NIL") or have their
parent set to themselves ("parentThing == SELF"). Do those predicate
forms sound right?
Normally I would just test this myself and fumble around, but since I
can't seem to get the PredicateEditorSample example to work on my
machine (finds nothing in my large address book), I'm a little spooked
right now.
My other question is regarding the mundanity of doing a Core Data
document based app version versus an old skool Cocoa one, especially
one that used a file package for document storage.
I'm realizing that I have a lot of state in my document that's
specific to the document (i.e. not application settings). Normally,
these would be instance variables of my NSDocument subclass that I
would load/save as part of my document data.
It seems more Core Dataish, though, to make an NSManagedEntity to hold
these values, and then perhaps cache the values in a property of the
NSManagedDocument subclass as I open up. Assuming that is best
practice, though, here's my concern:
Assuming I have a MyThing, and MyThing can have a single parent
MyThing and some number of child MyThings.
In my DocInfo entity, I want to hold onto several different MyThings:
two single ones (called bigKahuna and currentThing) and a set of them
(called topThings).
In other words, I have 2 one-to-one relationships to MyThing in
DocInfo, and 1 one-to-many relationships, all of which are pointing to
MyThing.
Given Core Data's penchant (understandable!) for inverse
relationships, I'm okay with putting a docInfo relationship in
MyThing, I wanted to confirm that it's cool to overload it that way,
i.e. all 3 of the relationships hanging off of DocInfo using MyThing's
docInfo as their inverse relationship.
As always, thanks for any insight. Looking forward to getting my
third Core Data under my belt so my intuition for this stuff widens...
--> Michael B. Johnson, PhD
--> http://homepage.mac.com/drwave (personal)
--> http://xenia.media.mit.edu/~wave (alum)
--> MPG Lead
--> Pixar Animation Studios
_______________________________________________
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