I have a .plist file that is loaded into my Xcode project. I have successfully put it in the documents directory of my iPhone while testing it. When I dump the contents into an NSMutableDictionary, and try to enumerate it, I get EXC_BAD_ACCESS crashes. They keys all have BOOLs associated as their values. What am I doing wrong?
My code now:
for (id key in achDict) {
NSLog(@"Achievement:%@ done:%@", key, [[achDict objectForKey:key] boolValue]);
}
This always returns EXC_BAD_ACCESS in a crash.
Your NSLog is expecting two objects but you are passing it a string ‘key’ and an Integer. A Bool Value is not an Object, it returns an Integer value (0 for False and 1 for True).
%@is for Objective C Objects. Instead use%dto get Integer Values such as C Booleans.Change your NSLog statement to:
Apple’s String Programming Guide has a useful section on String Modifiers