• 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: CoreData "in" predicate
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CoreData "in" predicate


  • Subject: Re: CoreData "in" predicate
  • From: Frederick Reimer <email@hidden>
  • Date: Sun, 2 May 2010 16:32:15 -0400

Unfortunately, there is nothing for the NSPredicate class to go on to assume what object you are talking about.  predicateWithFormat is a class method/selector/function.  What object is it supposed to assume you mean if one is not supplied?

Dan Rowley sent me an email saying you may be able to use "self."  So, I assume this means:

NSPredicate *pred = [NSPredicate predicateWithFormat: @"%K in %@", self, favoriteMissions];

HTH,

On May 2, 2010, at 9:03 AM, Rick Mann wrote:

> I saw that, I had hoped that by not specifying an attribute, it would mean the object itself, not an attribute on the object.
>
>
> On May 2, 2010, at 05:58:39, Frederick Reimer wrote:
>
>> The manuals for this give the following example:
>>
>> NSPredicate *inPredicate =
>>            [NSPredicate predicateWithFormat: @"attribute IN %@", aCollection];
>>
>> It looks like you are missing the attribute...  If attribute can vary, you can use a %K and a NSString value representing the attribute name (it is not automatically enclosed in quotes as %@ values are).
>>
>> HTH,
>>
>> Fred
>> On May 2, 2010, at 8:27 AM, Rick Mann wrote:
>>
>>> Hi.
>>>
>>> I have two entities: Mission and Favorite. Favorite has a single relation to Mission. I need to fetch all Mission objects that exist in Favorite. I'm using an NSFetchResultsController.
>>>
>>> I created an array with all the Mission objects found in the Favorite entity. Then I tried to create a predicate like this:
>>>
>>> 	NSPredicate* pred = [NSPredicate predicateWithFormat: @"in %@", favoriteMissions];
>>>
>>> and use that on a fetch of Mission objects. But it complains that it can't parse that format string.
>>>
>>> Clearly, this approach isn't going to work. I could store the Mission's key in the Favorite table instead, but that's less elegant. Might be the only way to go.
>>>
>>> Any suggestions?
>>>
>>> tia,
>>> Rick
>>>
>>> _______________________________________________
>>>
>>> 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
>>>
>>
>
>

Fred Reimer, CCIE 23812 CISSP 107125
mailto:email@hidden



_______________________________________________

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

  • Follow-Ups:
    • Re: CoreData "in" predicate
      • From: Frederick Reimer <email@hidden>
References: 
 >CoreData "in" predicate (From: Rick Mann <email@hidden>)
 >Re: CoreData "in" predicate (From: Frederick Reimer <email@hidden>)
 >Re: CoreData "in" predicate (From: Rick Mann <email@hidden>)

  • Prev by Date: Re: CoreData "in" predicate
  • Next by Date: Re: CoreData "in" predicate
  • Previous by thread: Re: CoreData "in" predicate
  • Next by thread: Re: CoreData "in" predicate
  • Index(es):
    • Date
    • Thread