• 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: Many-to-many coredata fetch request
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Many-to-many coredata fetch request


  • Subject: Re: Many-to-many coredata fetch request
  • From: Andrew Cooper <email@hidden>
  • Date: Wed, 31 May 2006 02:34:05 -0500

I am by no means a Predicates expert, but according to
http://developer.apple.com/documentation/Cocoa/Conceptual/Predicates/ Articles/pSyntax.html#//apple_ref/doc/uid/TP40001795-215891
of the http://developer.apple.com/documentation/Cocoa/Conceptual/ Predicates/ Guide, shouldn't your left and right-hand sides be switched?


[quote]
IN

Equivalent to an SQL IN operation, the left-hand side must appear in the collection specified by the right-hand side. For example, name IN { 'Ben', 'Melissa', 'Matthew' }.
[/quote]


By that definition, you have your target names trying to be in people.name instead of the other way around.

Hope that helps.
- Andrew Cooper -

On May 31, 2006, at 2:14 AM, email@hidden wrote:

Hi all,

I'm having a bit of a trouble getting fetch to execute right.
I have an entity that contains a to-many relation. In the objects of that relation are string values I want to search for.


So its like this:

Entity A ->> EntityWithStrings (e.g names)

So I want to do a search that takes an array of names (multiple selection) and search for objects that contain any of those names.

Someting like "ANY object.tomany.name IN myArrayOfNames"



Here is how I'm constructing my predicate:

NSArray *allNames = [[self selectedObjects] valueForKey:@"name"];

NSExpression *targetKeyPath = [NSExpression expressionForKeyPath:@"people.name"];
NSExpression *targetNames = [NSExpression expressionForConstantValue: allNames];

NSPredicate *weakPredicate = [NSComparisonPredicate predicateWithLeftExpression: targetNames
rightExpression: targetKeyPath
modifier: NSAnyPredicateModifier
type: NSInPredicateOperatorType
options:0];




Andre
email@hidden



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40gmail.com


This email sent to email@hidden

_______________________________________________ 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: Many-to-many coredata fetch request
      • From: email@hidden
References: 
 >Many-to-many coredata fetch request (From: email@hidden)

  • Prev by Date: Re: NSPersistentStoreCoordinator not supported in 10.3.9?
  • Next by Date: Re: NSPersistentStoreCoordinator not supported in 10.3.9?
  • Previous by thread: Many-to-many coredata fetch request
  • Next by thread: Re: Many-to-many coredata fetch request
  • Index(es):
    • Date
    • Thread