码迷,mamicode.com
首页 > 其他好文 > 详细

Dictionary and Array value cannot be nil

时间:2015-01-28 19:51:05      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:__nsplaceholderdicti   __nsplaceholderarray   dictionary value can   array element cannot   

Dictionary value cannot be nil
Terminating app due to uncaught exception ‘NSInvalidArgumentException‘, reason: ‘*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[2]‘
*** First throw call stack:
 NSString *a;
  dic2 = @{
            
@"key":@"value",
             
@"ko":@"",
            
@"xue":a
             };

 Array element cannot be nil
Terminating app due to uncaught exception ‘NSInvalidArgumentException‘, reason: ‘*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[2]‘
*** First throw call stack:
 NSString *a;
 array2 = @[@"",@"0",a];


测试:数组不能有nil的对象,字典不能插入nil的值
-(void)setData{
   
   
NSDictionary *dic1;
   
NSArray *array1;
    dic1 =
@{};
    array1 =
@[];
   
NSLog(@"dic1:%@",dic1);
   
NSLog(@"array1:%@",array1);
   
   
NSDictionary *dic2;
   
NSArray *array2;
   
NSString *a;
//    a=nil;
    dic2 =
@{
            
@"key":@"value",
             
@"ko":@"",
            
@"xue":a
            
};
    array2 =
@[@"",@"0",a];
   
NSLog(@"dic2:%@",dic2);
   
NSLog(@"array2:%@",array2);


}




Dictionary and Array value cannot be nil

标签:__nsplaceholderdicti   __nsplaceholderarray   dictionary value can   array element cannot   

原文地址:http://blog.csdn.net/u010241322/article/details/43234529

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!