Sorry about the weird title… all will be explained.
Basically I have an array/dictionary structure like this in my app:
NSArray {
NSDictionary {
(NSString *)id;
(NSDictionary *)dictionary;
}
NSDictionary {
(NSString *)id;
(NSDictionary *)dictionary;
}
NSDictionary {
(NSString *)id;
(NSDictionary *)dictionary;
}
etc...
}
Hope that’s easy to work out…
Now I have an (NSString *)id and I want to get the (NSDictionary *)dictionary which corresponds to it.
Is there any way that I can do this?
Thank you
Tom
Try something like this
for (NSDictionary *dict in dictArray) { if ([[dict objectForKey:@"id"] isEqualToString:targetID]){ return [dict objectForKey:@"dictionary"]; } }I have not compiled the code(don’t have mac near me), but I think you got the idea. The basic idea is to loop through the array and compare query string. But if you have many items then this linear search might be time consuming.