The two problems:
- Loading the plist into an NSDictionary:
This is a simple problem, which it seems you have already figured out. The global object in your plist is an array, not a dict, so when you load it into the dictionary, it doesn't know what to do (incompatable types), so you're getting an empty dictionary.
- Looping through the array of dictionaries:
From the Exception you're getting, you are calling 'setObject:forKey:' on the dictionary, which is initialized as an NSDictionary, not an NSMutableDictionary. The pointer is typed as NSMutableDictionary, but not the actual in memory object. You need to change your line from.
NSMutableDictionary *myDic = [[NSDictionary alloc] initWithContentsOfFile:path];
to
NSMutableDictionary *myDic = [[NSMutableDictionary alloc] initWithContentsOfFile:path];
and actually, since loading the dictionary from the file gives you an empty dictionary, you are wasting cycles trying to load it from the file, and should just create a new one:
NSMutableDictionary *myDic = [[NSMutableDictionary alloc] init];
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…