如何在iOS中从Plist检测keyType Boolean或not
我有一个要求,我想检测特定键的值在plist中是否为Boolean类型。使用以下代码,我正在从bundle加载plist:如何在iOS中从Plist检测keyType Boolean或not,ios,iphone,plist,Ios,Iphone,Plist,我有一个要求,我想检测特定键的值在plist中是否为Boolean类型。使用以下代码,我正在从bundle加载plist: NSString *filePath = [[NSBundle mainBundle] pathForResource:@"myPlist" ofType:@"plist"]; NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:filePath]; id developer = [dict o
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"myPlist" ofType:@"plist"];
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:filePath];
id developer = [dict objectForKey:@“iOSDeveloper];
我的plist看起来像这样:
Key Type value
iosDeveloper Boolean YES
如果用户将类型更改为NSNumber、NSArray、NSDictionary等,而不是Boolean,我想打印类似于日志的select type Boolean for iOSDeveloper keyBoolean是另一个名称的NSNumber。您试图检测数组/字典的内容是什么?如果[developer iskindof class[NSNumber class]],我会这样做。这里的问题是如果我选择类型NSArray,NSDictionary。。。。它为iOSDeveloper键打印类似日志的选择类型布尔值。如果我选择类型NSNumber,它不会给我日志。您最好允许NSNumber,但检查值是否为0或1,如果不是,则记录。。。