• 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: Issue with fast enumeration of dictionary
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Re: Issue with fast enumeration of dictionary (From: Bryan Henry <email@hidden>)

  • Prev by Date: Re: Issue with fast enumeration of dictionary
  • Next by Date: Re: turn off function parameter indent on paste?
  • Previous by thread: Re: Issue with fast enumeration of dictionary
  • Next by thread: Delete group in Xcode 3.1 with SCM
  • Index(es):
    • Date
    • Thread