• 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
Core Data: Need help with fetch request
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Core Data: Need help with fetch request


  • Subject: Core Data: Need help with fetch request
  • From: Diederik Hoogenboom <email@hidden>
  • Date: Tue, 10 Oct 2006 21:27:37 +0200

I want to fetch some objects based on a condition existing in one of its relationships.

Example Object Model:

Car -> Wheel

A car can have one or more wheels. And a wheel has a property called color (to keep it simple an NSString). The relationship is called wheels. There is no inverse relationship.
What I want is to retrieve all cars that a color that contains the word 'black'.


Code I've tried so far:

NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"Car" inManagedObjectContext:context];
NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease];
[request setEntity:entityDescription];
NSPredicate *predicate = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"ANY wheels.color like '*black*'] ];
[request setPredicate:predicate];
NSArray *array = [context executeFetchRequest:request error:nil];



Unfortunately the fetch request does result in any objects retrieved. I am using an SQL-lite store for this example.

Kind regards,

Diederik


_______________________________________________
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: Core Data: Need help with fetch request
      • From: Jakob Olesen <email@hidden>
  • Prev by Date: Re: Creating NSURL from Apple Event string
  • Next by Date: Re: Creating NSURL from Apple Event string
  • Previous by thread: MEETING: Reminder - Los Angeles - CocoaHeads October 12th
  • Next by thread: Re: Core Data: Need help with fetch request
  • Index(es):
    • Date
    • Thread