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);
}