Re: Issue with fast enumeration of dictionary
Re: Issue with fast enumeration of dictionary
- Subject: Re: Issue with fast enumeration of dictionary
- From: Bill Cheeseman <email@hidden>
- Date: Thu, 24 Jul 2008 08:42:47 -0400
- Thread-topic: Issue with fast enumeration of dictionary
on 2008-07-24 8:32 AM, Bryan Henry at email@hidden wrote:
> Fast enumeration in Objective-C enumerates through the keys, not
> through the keys' objects. This is what you want:
>
> + (NSArray *)observersForPid:(pid_t)pid {
> NSMutableArray *outArray = [NSMutableArray array];
> for (id *key in observersDictionary) {
> dictionary = [observersDictionary objectForKey:key];
> if ([[dictionary objectForKey:@"pidNumberKey"] intValue] ==
> pid) {
> [outArray addObject:[dictionary
> objectForKey:@"observerKey"]];
> }
> }
> return [[outArray copy] autorelease]; // immutable
> }
Oh dear. That seems pretty obvious from the Objective-C 2.0 document, now
that you mention it. I'll give it a try this evening.
Thanks.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
www.quecheesoftware.com
PreFab Software - www.prefabsoftware.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden