[iOS] for each loop in objective c for accessing NSMutable dictionary
阿新 • • 發佈:2018-12-27
如何瀏覽所有NSMutableDictionary 裡的內容?
NSMutableDictionary *xyz=[[NSMutableDictionary alloc] init];
解答:
for (NSString* key in xyz) {
id value = [xyz objectForKey:key];
// do stuff
}
This works for every class that conforms to the NSFastEnumeration protocol (available on 10.5+ and iOS), though NSDictionary
Oh, I should add however that you should NEVER modify a collection while enumerating through it.
from: