I need to get last 10 elements or min of 10 and array.count. In objective-C I have done it like this :
Objective-C code :
NSRange endRange = NSMakeRange(sortedArray.count >= 10 ? sortedArray.count - 10 : 0, MIN(sortedArray.count, 10));
NSArray *lastElements= [sortedArray subarrayWithRange:endRange];
In Swift I have done this :
let endRange = NSMakeRange(values.count >= 10 ? values.count - 10 : 0, min(values.count , 10) )
But don't know how to get the array using this range in swift. Any help would be appreciated. Thanks.