从NSMutableArray获取最后五个值 [英] Fetch last five values from NSMutableArray
问题描述
我有一个 EDIT :小心检查您的数组是否至少有五个元素,否则 I have a I think that EDIT : Be careful to check that your array has at least five elements, else, 这篇关于从NSMutableArray获取最后五个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! NSMutableArray
,其计数为10,我想提取最后5个值,并将它们存储在另一个数组中。 我认为 - (NSArray *)subarrayWithRange:(NSRange)范围
(
NSRange theRange;
theRange.location = [wholeArray count] - 5;
theRange.length = 5;
NSArray * result = [wholeArray subarrayWithRange:theRange];
subarrayWithRange
会抛出异常。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?- (NSArray *) subarrayWithRange:(NSRange)range
(doc) might help you.NSRange theRange;
theRange.location = [wholeArray count] - 5;
theRange.length = 5;
NSArray *result = [wholeArray subarrayWithRange:theRange];
subarrayWithRange
will throw an exception.