我正在尝试将值写入plist,但有错误
代码:
NSString *path = [[NSBundle mainBundle] pathForResource:@"Properties" ofType:@"plist"];
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path];
[dict setObject:[NSNumber numberWithInt:Quant] forKey:@"Quant"];
[dict writeToFile:path atomically:YES];
错误:
No visible @interface for 'NSDictionary' declares the selector 'setObject:forKey:'
答案 0 :(得分:0)
您无法修改不可变的NSDictionary。你必须使用可变副本:
NSMutableDictionary *dict = [[[NSDictionary alloc] initWithContentsOfFile:path] mutableCopy];