• 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
Object Identity Tests in Core Data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Object Identity Tests in Core Data


  • Subject: Object Identity Tests in Core Data
  • From: Niko Matsakis <email@hidden>
  • Date: Tue, 30 Aug 2005 15:45:05 +0200

I am building on the excellent Core Data framework and I have a question. It often happens that I would like to build a query where I want to find all entities with a reference equal to a given object. Is there a good way to do this?

Allow me to use an example to clarify because I can't even understand what I wrote in that previous paragraph:

Let's say I have an application with two types of entities: Word and User. Each Word has a relationship "user" that indicates which user it is associated with. I now want to select for the current user the set of all of the words associated with them.

As far as I can tell, the predicate language doesn't really work with pointers as much as strings and scalar fields. So, the way I do this today is to require that each user have a unique name, and then encode a fetch request for Word entities with a predicate like:

   "user.name == $USERNAME"

and in my code I ensure that $USERNAME is bound to [userObject valueForKey:@"name"].

What I would like to do is to instead use object references so that there are no assumptions about whether or not the names are unique. For example, I might do:

    "user == $USEROBJECT"

and bind $USEROBJECT to userObject in my code.

Will this work? If not, is there a way to do what I want? Is my question clear?


Thanks in advance.

Niko
_______________________________________________
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


  • Follow-Ups:
    • Re: Object Identity Tests in Core Data
      • From: Chris Hanson <email@hidden>
  • Prev by Date: Re: Problem with converting an NSImage to grayscale
  • Next by Date: NSScrollView: iPhoto/iTunes border type?
  • Previous by thread: Re: NSKeyedArchiver - alternatives for speed improvements?
  • Next by thread: Re: Object Identity Tests in Core Data
  • Index(es):
    • Date
    • Thread