Looping through values in NSDictionary throws fault
Posted
by jud
on Stack Overflow
See other posts from Stack Overflow
or by jud
Published on 2010-05-03T22:33:28Z
Indexed on
2010/05/03
22:38 UTC
Read the original article
Hit count: 283
I have a plist file that I am loading into an NSDictionary *setDictionary that contains a set of fields, pictureDesc1, pictureDesc2, etc.
Once the NSDictionary is loaded, I can retrieve a value using
[setDictionary objectForKey:@"pictureDesc1"];
But I cannot do a loop like this:
for (int i=1; i<=numberOfPictures; i++) {
NSString *keyName = [NSString stringWithFormat:@"pictureDesc%d",i];
NSString *description = [NSString stringWithFormat:@"%@", [setDictionary objectForKey:keyName]];
}
Is there a different way to dynamically call keys from within an NSDictionary?
© Stack Overflow or respective owner