Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
正如标题所述,如果我将一个空的 NSIndexSet 传递给 inobjectsAtIndexs:方法NSArray,它返回 nil 还是一个空的 NSArray?
objectsAtIndexs:
NSArray
谢谢!
文档指出,只要您的索引集不包含超出数组边界的索引,并且索引集不为零,您就会返回一个数组。如果索引集被认为是有效的,那么返回一个 nil 数组将是厚颜无耻的,因为这不是调用者和接收者之间的约定。
因此,您将返回一个空数组。
Source: https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/NSArray.html#//apple_ref/occ/instm/NSArray/objectsAtIndexes: