Why not write it like so...

Sandor Szatmari

> On Jul 13, 2015, at 10:52, Alex Zavatone <z...@mac.com> 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)

> 
> 
> 
> 
> 
>> On Jul 13, 2015, at 10:35 AM, Alex Zavatone wrote:
>> 
>> Hi all.  I've got a dictionary of objects that contain properties and need 
>> to check if one object has a certain value.
>> 
>> I was thinking I could use collection operators and build an array where the 
>> value of an an object's property matches that I'm looking for.
>> 
>> Then if the array contains that value, we have a match.  
>> 
>> If each objects in the array has a bunch of properties and one of those 
>> properties is called "thing", how would I build an array where the contents 
>> of thing would equal a certain value?
>> 
>> I'm sure I could walk the array, but I expect there is a more efficient 
>> method already built in to Cocoa for this.
>> 
>> Thanks in advance.
>> 
>> Alex Zavatone
>> _______________________________________________
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> 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:
>> https://lists.apple.com/mailman/options/cocoa-dev/zav%40mac.com
>> 
>> This email sent to z...@mac.com
> 
> 
> _______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> 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:
> https://lists.apple.com/mailman/options/cocoa-dev/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari....@gmail.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to