首页 > 代码库 > Dictionary and Array value cannot be nil
Dictionary and Array value cannot be nil
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
@"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);
}
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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。