Re: seemingly simple Core Data fetch question
Re: seemingly simple Core Data fetch question
- Subject: Re: seemingly simple Core Data fetch question
- From: Gonzalo Castro <email@hidden>
- Date: Wed, 29 Aug 2007 23:24:37 -0400
Thank you for the pointer.
Using a formatted predicate with variable substitution I could make
the Department managed object be part of the equation. See
"myDepartment == %@" below.
NSEntityDescription *entityDescription = [NSEntityDescription
entityForName: @"Employee" inManagedObjectContext:
myManagedObjectContext];
NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
[request setEntity: entityDescription];
NSManagedObject *theDepartment = /* the selected Department */;
NSPredicate *predicate = [NSPredicate predicateWithFormat:
@"(myCompanyCar == NIL) AND (myDepartment == %@)", theDepartment];
[request setPredicate: predicate];
NSError *error = nil;
NSArray *fetchResult = [myManagedObjectContext executeFetchRequest:
request error: &error];
This gets me the employees within a department that have no company
car assigned to them.
Gonzalo
On Aug 28, 2007, at 11:31 PM, mmalc crawford wrote:
On Aug 28, 2007, at 7:39 PM, Gonzalo Castro wrote:
I'm not sure how to refer to a specific managed object in the
predicate.
<http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/
Articles/cdFetching.html>
mmalc
_______________________________________________
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