Question: I have an `NSArray` of `NSDictionary`.
Each dictionary in the array has three keys: 'Name', 'Sex' and 'Age'

How can I find the index in `NSArray` of `NSDictionary` where, for example, `Name = 'Roger'`?

Answer: 
On iOS 4.0 and up you can do the following:

```
- (NSUInteger) indexOfObjectWithName: (NSString*) name inArray: (NSArray*) array
{
    return [array indexOfObjectPassingTest:
        ^BOOL(id dictionary, NSUInteger idx, BOOL *stop) {
            return [[dictionary objectForKey: @"Name"] isEqualToString: name];
    }];
}

```

Elegant, no?
There's method [NSArray indexOfObjectPassingTest]. But it employs blocks, an Apple extension to C, and therefore is evil. Instead, do this:

```
NSArray *a; //Comes from somewhere...
int i;
for(i=0;i<a.count;i++)
    if([[[a objectAtIndex:i] objectForKey: @"Name"] compare: @"Roger"] == 0)
        return i; //That's the index you're looking for
return -1; //Not found

```