• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
a few Core Data questions: Predicates and document based app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: a few Core Data questions: Predicates and document based app
      • From: mmalc Crawford <email@hidden>
  • Prev by Date: Re: -[NSURLConnection cancel] doesn't release its delegate?
  • Next by Date: Re: Error with malloc and NSFileWrapper
  • Previous by thread: Re: Age Old Question: How Do You Set __MyCompanyName__
  • Next by thread: Re: a few Core Data questions: Predicates and document based app
  • Index(es):
    • Date
    • Thread