• 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
Re: Predicates with object identity values
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Predicates with object identity values


  • Subject: Re: Predicates with object identity values
  • From: Aurélien Hugelé <email@hidden>
  • Date: Fri, 25 May 2007 06:09:58 +0200

Glen, there is a small confusion in your explanation:
A Department object has many Employee objects

and

here is a relation Department -> Employee (employee)

The convention is to use ->> (double arrow) to indicate a to many relationship, and to use plurals (employeeS).


If you have a to one relationship Department -> Employee (employee), yes your predicate is correct and your FetchRequest is valid.

But if you have a to many relationship Department ->> Employee (employees)
you'll have to use something like "ANY employees == %@,myEmployee" // not actually tested


Aurélien


On 25 mai 07, at 02:41, Glen Low wrote:

Hi All

In Core Data, specifically predicate programming, is it possible to create a NSPredicate to search on an object identity value (as opposed to a string, number or bool value)?

For example, suppose

A Department object has many Employee objects. There is a relation Department -> Employee (employee) but no inverse relation Employee - > Department.

Suppose I have an Employee object called myEmployee and want to search for its Department, can I use the following fetch request?

NSFetchRequest* request = [[NSFetchRequest alloc] init];
[request setEntity: departmentEntity];
[request setPredicate: [NSPredicate predicateWithFormat: @"employee = %@", myEmployee]]; // using myEmployee as an object identity


If not, I'd probably have to assign each object a unique, persistent ID, which is a bit of a pain... or are they any other solutions?




Cheers, Glen Low


--- pixelglow software | simply brilliant stuff www.pixelglow.com aim: pixglen

_______________________________________________

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:
40gumitech.com


This email sent to email@hidden


_______________________________________________

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


  • Prev by Date: Re: Run a process as root (asking only one time the root password)
  • Next by Date: checking a launched program before launching a new one
  • Previous by thread: Re: Run a process as root (asking only one time the root password)
  • Next by thread: checking a launched program before launching a new one
  • Index(es):
    • Date
    • Thread