• 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: NSPredicate or Collection operators?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSPredicate or Collection operators?


  • Subject: Re: NSPredicate or Collection operators?
  • From: Alex Zavatone <email@hidden>
  • Date: Mon, 13 Jul 2015 13:45:19 -0400

On Jul 13, 2015, at 1:27 PM, Sandor Szatmari wrote:

> Why not write it like so...
>
> Sandor Szatmari
>
>> On Jul 13, 2015, at 10:52, Alex Zavatone <email@hidden> wrote:
>>
>> Ahh, well, it turns out that I had the code right in the first place.
>>
>> Here it is if anyone needs to do the same thing.
>>
>>  BOOL isItemPresentWithIdenticalValue = NO;
>>
>>   NSArray *allObjects = [self.geofenceObjects allValues];
>>   NSArray *allOccurrencesOfSourceValue = [allObjects valueForKey:@"smi" ];
>>
>>   isItemPresentWithIdenticalValue = [allOccurrencesOfSourceValue containsObject:thingWeAreCheckingFor]
>> ;
>
> BOOL itemIsPresentWithIdenticalValue = [[[self.geofenceObjects allValues] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"smi == %@", thingWeAreCheckingFor]] count] > 0;
>
> That is if all you want to know is 'if an object exists with a value'
>
> (Written in mail, forgive any typos)

Yeah, I was wondering if I should have used an NSPredicate or not.

I'm not a fan of mashing everything together into one line as it makes readability and comprehension an issue, but this is exactly what I was looking for.

It's been at least a few years since I used predicates, that's for sure.  Thanks.

Thank you, Sandor.

Cheers,
Alex Zavatone
_______________________________________________

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: NSPredicate or Collection operators?
      • From: Martin Wierschin <email@hidden>
References: 
 >NSPredicate or Collection operators? (From: Alex Zavatone <email@hidden>)
 >Re: NSPredicate or Collection operators? (From: Alex Zavatone <email@hidden>)
 >Re: NSPredicate or Collection operators? (From: Sandor Szatmari <email@hidden>)

  • Prev by Date: Re: NSPredicate or Collection operators?
  • Next by Date: Re: Terminate app
  • Previous by thread: Re: NSPredicate or Collection operators?
  • Next by thread: Re: NSPredicate or Collection operators?
  • Index(es):
    • Date
    • Thread