As the title states, if I pass in an empty NSIndexSet to objectsAtIndexs: method in NSArray, does it return nil, or an empty NSArray?
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The documentation states that you will get an array returned, as long as your index set doesn’t contain an index that exceeds the bounds of the array, and the index set isn’t nil. It’d be cheeky of them to return a nil array if the index set was deemed valid, as that’s not what the contract between the caller and the receiver states.
As such, you’ll get an empty array returned.
Source: https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/NSArray.html#//apple_ref/occ/instm/NSArray/objectsAtIndexes: