美文网首页
NSArray difference between first

NSArray difference between first

作者: iLynn | 来源:发表于2017-12-14 11:15 被阅读0次

NSArray *array = [NSArray new];
id obj1 = [array firstObject]; // this is giving nil value
id obj2 = [array objectAtIndex:0]; // this line crashes

Using firstObject is a system defined API which returns nil if there is none. But if you try to access objectAtIndex it will give NSRange exception and app will crash.

相关文章

网友评论

      本文标题:NSArray difference between first

      本文链接:https://www.haomeiwen.com/subject/ftnhwxtx.html