iPhone SDK Nested For Loop performance

Posted by Skeep on Stack Overflow See other posts from Stack Overflow or by Skeep
Published on 2010-04-28T08:27:08Z Indexed on 2010/04/28 8:33 UTC
Read the original article Hit count: 305

Filed under:
|
|

Hi All,

I have a NSArray of string id and a NSDictionary of NSDictionary objects. I am currently looping through the string id array to match the id value in the NSDictionary.

There are around 200 NSDictionary objects and only 5 or so string ID.

My current code is such:

for (NSString *Str in aArr) {
        for (NSDictionary *a in apArr)
        {
            if ([a objectForKey:@"id"] == Str)
            {
            NSLog(@"Found!");
            }
        }
}

The performance of the above code is really slow and I was wondering if there is a better way to do this?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about iphone-sdk