Predicates with object identity values
Predicates with object identity values
- Subject: Predicates with object identity values
- From: Glen Low <email@hidden>
- Date: Fri, 25 May 2007 08:41:51 +0800
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:
This email sent to email@hidden