How to slice an NSArray in Objective-C?

2020-03-08 07:53发布

问题:

What's the simplest way to extract a slice of an NSArray in Objective-C?

(much like the array_slice function in PHP)

回答1:

-[NSArray subarrayWithRange:]

Reference:
https://developer.apple.com/documentation/foundation/nsarray/1415157-subarraywithrange