• 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: seemingly simple Core Data fetch question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >seemingly simple Core Data fetch question (From: Gonzalo Castro <email@hidden>)
 >Re: seemingly simple Core Data fetch question (From: mmalc crawford <email@hidden>)

  • Prev by Date: Cocoa and WebObjects, Webkit....
  • Next by Date: WebCore.....
  • Previous by thread: Re: seemingly simple Core Data fetch question
  • Next by thread: Re: seemingly simple Core Data fetch question
  • Index(es):
    • Date
    • Thread