plistからBOOL型のデータを取得する方法
plistからBOOL型のデータを取得しようとしたら、NULLが返ってきて常にNOになってて少しハマった。
どうやらBOOL型のデータの場合、objectForKeyで取得したデータを更にboolValueでBOOL型に変えないとあかんらしいのでメモ。
NSString *filePath = [homeDir stringByAppendingPathComponent:@"hoge.plist"];
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:filePath]) { // yes
NSLog(@"plistが存在しません.");
return;
}
NSDictionary *output = [NSDictionary dictionaryWithContentsOfFile:filePath];
// String型のデータの取得
[output objectForKey:key]
// Bool型のデータの取得
[[output objectForKey:key] boolValue]