I have a NSMutableArray
whose count is 10 and I want to extract the last 5 values and store them in another array. How can I do this?
I think that - (NSArray *) subarrayWithRange:(NSRange)range
(doc) might help you.
NSRange theRange;
theRange.location = [wholeArray count] - 5;
theRange.length = 5;
NSArray *result = [wholeArray subarrayWithRange:theRange];
EDIT : Be careful to check that your array has at least five elements, else, subarrayWithRange
will throw an exception.