我从plist文件中读取问题 我的Settings.plist文件保存在我的项目中(尝试进出资源文件夹) 没有任何方法谷歌和stackOverFlow必须提供工作。我不知道我错过了什么。 代码:从plist中读取
NSString *pListPath = [[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"plist"];
NSMutableDictionary *settings = [[[NSMutableDictionary alloc] initWithContentsOfFile:pListPath] retain];
BOOL touch = [[settings objectForKey:@"Touch"] boolValue];
NSLog(@"%@",touch ? @"TOUCH IS YES" : @"TOUCH IS NO");
我试图获得* plistPath许多不同的方法,一个NSBundle,只是一个文件名字符串。还试过NSMutabelDictionary,regulat NSDictionary,NSArray,NSMutableArray
没有什么似乎工作。 尝试plist中第一行设置为根字典,仍然没有运气..
任何帮助将apreciated .. Settings.plist有一个单一的价值Touch和它的关键是YES 非常感谢!
编辑: 这里的plist中:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Root</key>
<dict>
<key>Touch</key>
<true/>
</dict>
</dict>
</plist>
什么是'settings'后'initWithContentsOfFile值:'回报?另外,编辑你的问题并粘贴在'Settings.plist'文件的内容中。 – 2012-02-02 03:36:34
如何判断它自己的设置的值? – 2012-02-02 03:43:46
使用'NSLog'或调试器。 – 2012-02-02 03:49:50