I’m using a property-file with this structure:
maxRating Number --> 5
gradePercent Dictonary
>grade1 Number --> 0.85
>grade2 Number --> 0.70
>grade3 Number --> 0.55
>grade4 Number --> 0.40
To read the properties I’m using
NSDictionary *plist = [[NSDictionary alloc] initWithContentsOfFile:filepath];
rating = [[plist objectForKey:@"maxRating"] intValue];
gradePercent = (NSMutableDictionary*)[[plist objectForKey:@"gradePercent"] copy];
Till here every thing works perfectly…I can get the right objects with [gradePercent objectForKey:@"grade1"]
but when I try to set one of them with
[gradePercent setObject:[NSNumber numberWithFloat:0.90] forKey:@"grade1"]
I always get a SIGABRT error and the APP is crashing.
Does anyone see why this isn’t working? Because I don’t -.-
An
NSDictionaryis immutable, and simply casting the pointer toNSMutableDictionary *doesn’t make the object magically become mutable. So you need a mutable dictionary. You could do it like this: