iphone – 从BOOL值的plist问题读取NSDictionary

iphone – 从BOOL值的plist问题读取NSDictionary,第1张

概述所以我有以下方法: - (void)readPlist{ NSString *path = [[NSBundle mainBundle] pathForResource:@"States" ofType:@"plist"]; self.data = [[NSMutableDictionary alloc] initWithContentsOfFile:path]; 所以我有以下方法:

- (voID)readPList{    Nsstring *path = [[NSBundle mainBundle] pathForResource:@"States" ofType:@"pList"];        self.data = [[NSMutableDictionary alloc] initWithContentsOffile:path];    BOol value = (BOol)[self.data valueForKey:@"Arizona"];    NSLog(@"VALUE IS %d",value);}

读取pList罚款,它可以检测到它有7个键,但是当我尝试打印的值,它给我32如果它是一个no和24如果是一个是的.我究竟做错了什么?

解决方法 valueForKey返回一个ID.做这个:

NSNumber * n = [self.data valueForKey:@"Arizona"];BOol value = [n boolValue];
总结

以上是内存溢出为你收集整理的iphone – 从BOOL值的plist问题读取NSDictionary全部内容,希望文章能够帮你解决iphone – 从BOOL值的plist问题读取NSDictionary所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1083397.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存