【发布时间】:2014-04-09 11:25:05
【问题描述】:
尝试执行以下操作:
NSMutableArray *tmpArr = [_tweets subarrayWithRange:NSMakeRange(0, 10)];
_tweets = [[NSMutableArray alloc] init]; // added this in trial and error debugging
_tweets = tmpArr;
_tweets 是一个NSMutableArray,我正在尝试从中获取前 10 个对象。
但是,我收到以下错误:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 157 beyond bounds [0 .. 9]'
有什么想法吗?
【问题讨论】:
-
这段代码后出现错误。
-
当您尝试从该数组中抓取前 10 个对象时显示代码。
-
@nhgrif 哦,什么!?调试器是否给出错误源自的任何形式的行号/类?
-
@Greg Er,这是它吗:
[_tweets subarrayWithRange:NSMakeRange(0, 10)];仍然是 iOS n00b :) -
没有。但是在发布的代码中,您没有尝试访问第 157 个元素。
标签: objective-c