2012-04-15 74 views
1

我是Xcode的新手。我想要的是在我的程序中读取plist数据。我得到了 NSArrayM insertObject:atIndex:]: object cannot be nil错误。这是我声明的和我的plist文件。感谢xcode NSArrayM insertObject:atIndex:]:object can not be nil

NSMutableArray *phoneArray; 

NSString *path=[[NSBundle mainBundle] pathForResource:@"PhoneList" ofType:@"plist"]; 

phoneArray= [[NSMutableArray alloc]initWithContentsOfFile:path]; 

密钥类型 项0字典 第1个字典

物品有描述,名称键作为String类型。

+1

youritems之一的plist是零... – 2012-04-15 12:16:14

回答

2

验证你的plist,最有可能是一个坏的价值。 NSArrayNSDictionary中的项目不能为空。您可以使用Xcode打开plist文件进行验证。

我个人使用“PlistEdit Pro”,当plist无效时,它可以提供更好的诊断。 PlistEdit Pro有一个Free Trial here

+0

感谢Zaph。计划有很大帮助。 – wseries 2012-04-15 19:41:37

+0

其实我错误地执行plist。外标签为,内标签为。再次感谢你。 – wseries 2012-04-16 01:16:09

0
- (void)insertObject:(id)anObject atIndex:(NSUInteger)index 

要添加到数组内容的对象。该值不能为零。

从plist文件的任何输入之前,请检查该元素是不是零,以避免EXCETION

+0

感谢WhiteTiger我做了NSLog(@“%@”,[dic objectForKey:@“Item 0”]); – wseries 2012-04-15 19:44:11

相关问题