New to Cocoa, and seem to be missing something.
What is the most elegant/idiomatic way to obtain the first x elements of an NSArray
as another N
firstNItems = [items subarrayWithRange:NSMakeRange(0, MIN(n, items.count))];
In Swift 3 you can use this:
let smallArray = largeArray.prefix(10)
2nd parameter is number of array items to include in the range, not the 'to' index
You can use subarrayWithRange:.
NSArray *smallArray = [largeArray subarrayWithRange:NSMakeRange(0, 10)];