What's the difference between [NSNull null] and nil?

后端 未结 6 679
[愿得一人]
[愿得一人] 2020-11-30 03:07

Here\'s a context where I have seen that:

NSMutableArray *controllers = [[NSMutableArray alloc] init];
for (unsigned i = 0; i < kNumberOfPages; i++) {
            


        
6条回答
  •  旧时难觅i
    2020-11-30 03:19

    You cannot add a nil value to an NSArray or NSMutableArray. If you need to store a nil value, you need to use the NSNull wrapper class, as shown in that snippet you have. This is specified in the documentation.

提交回复
热议问题