1、读取plist文件中的Boolean类型的字段值时,要先把它转为NSNumber类型,然后通过NSNumber的boolValue方法来读取该值。
jewel=[[dic objectForKey:@"jewel"]intValue];
globalData .isChineseLanguage =[[setting objectForKey : @"isChineseLanguage" ] boolValue ];
[dic setObject:[NSNumber numberWithInt:jewel] forKey:@"jewel"];
[setting setObject:[[NSNumber alloc]initWithBool:globalData.isChineseLanguage]forKey:@"isChineseLanguage"];
2读取部分
-(NSString *)getSettingpath{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory=[paths objectAtIndex:0];
NSString *path=[documentsDirectory stringByAppendingPathComponent:@"Setting.plist"];
//本地还没写入时,从配置中读取
if(![[NSFileManager defaultManager] fileExistsAtPath:path]) {
NSString *newpath = [[NSBundle mainBundle] pathForResource:@"Setting" ofType:@"plist"];
CCLOG(@"setting的初始路径%@",newpath);
setting=[[NSMutableDictionary alloc] initWithContentsOfFile:newpath];
[setting writeToFile:path atomically:YES];
}
return path;
}