Question: **I have an array of dictionaries**

```
for(int i = 0; i < 5; i++) {
    NSMutableDictionary *_myDictionary = [NSMutableDictionary dictionary];

    [_myDictionary setObject:[NSString stringWithFormat:@"%d",i] forKey:@"id"];
    [_myDictionary setObject:label.text @"Name"];
    [_myDictionary setObject:label1.text @"Contact"];
    [_myDictionary setObject:label2.text @"Gender"];
}

[_myArray addObject:_myDictionary];

```

**Now I want to pick a dictionary from the array whose objectForKey:@"id" is 1 or 2 or something else like there is an sql query Select \* from Table where id = 2. 
I know this process**

```
int index = [_myArray count];

for(int i = 0; i < 5; i++)
{

NSMutableDictionary *_myDictionary = [NSMutableDictionary dictionaryWithDictionary:[_myArray objectAtIndex:i]];

if([[_myDictionary objectForKey:@"id"] isEqualToString:id])
{

index = i;

return;

}

}

if(index != [_myArray count])
    NSLog(@"index found - %i",index);

else
    NSLog(@"index not found");

```

Any help would be appreciated.
Thanks in Advance !!!

Answer: 
Try this, this is by using fast enumeration

```
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    for(dict in _myArray)
    {

        if([[dict valueForKey:@"id"] isEqualToString:@"1"])
        {
            return;
        }
    }

```
You should use `[NSNumber numberWithInteger: i]` not a NSString.

Code fore this search should look like this:

```
NSString *valueToFind = [NSString stringWithFormat:@"%d", intValue]; // [NSNumber numberWithInteger: intValue] 
NSInteger index = [_myArray indexOfObjectPassingTest:^BOOL(NSDictionary *obj, NSUInteger idx, BOOL *stop) {
    return [valueToFind isEqualToString: [obj objectForKey: @"id"]];
}];
NSDitionary *found = [_myArray objectAtIndex: index];

```