【发布时间】:2011-07-06 08:38:01
【问题描述】:
我正在尝试将布尔值写入 plist 文件,但我真的不知道我在哪里做错了。我什至没有收到任何异常/错误,但相关文件中的值保持不变。而且文件路径也是正确的,myDict的分配表明已经从文件中读取了值。
下面是我写的代码
-(void)SetSettings:(BOOL)SoundOn: (BOOL)GlowOn
{
NSString *pathSettingFile = [[NSString alloc]initWithString:[[NSBundle mainBundle]pathForResource:@"AppSettings" ofType:@"plist"]];
NSMutableDictionary *myDict = [NSMutableDictionary dictionaryWithContentsOfFile:pathSettingFile];
[myDict setObject:[NSNumber numberWithBool:SoundOn] forKey:@"isSoundOn"];
[myDict setObject:[NSNumber numberWithBool:GlowOn] forKey:@"isGlowOn"];
[myDict writeToFile:pathSettingFile atomically:NO];
[myDict release];
[pathSettingFile release];
}
【问题讨论】:
标签: iphone objective-c xcode ios4