【发布时间】:2010-10-04 19:41:19
【问题描述】:
我有以下产生此错误的代码。我不明白为什么 subarrayWithRange 消息被发送到字符串?什么时候明明是数组?
static const int kItemsPerView = 20;
NSRange rangeForView = NSMakeRange( page * kItemsPerView, kItemsPerView );
NSMutableArray *temp = [[APP_DELEGATE keysArray] mutableCopyWithZone:NULL];
NSArray *itemsForView = [temp subarrayWithRange:rangeForView];
for (int loopCounter = 0;loopCounter < r*c;loopCounter++){
NSLog(@"%i: %@ ", loopCounter, [itemsForView objectAtIndex:loopCounter]);
}
错误:
-[NSCFString subarrayWithRange:]: unrecognized selector sent to instance 0x6b071a0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: [NSCFString subarrayWithRange:]:
谢谢
【问题讨论】:
标签: objective-c ios4 nsarray unrecognized-selector