我想知道如何通过 NSMutableArray 进行迭代,但是当我调用 objectAtIndex 时,它失败并显示“*** -[NSCFSet objectAtIndex:]: unrecognized selector sent to instance 0x ...”
这是一些示例代码,程序太大而无法完整分享,所以我希望它足够了。该代码在来自 XCode 的最新 iPhone 模拟器中执行。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
RDLogString(@"Creating cell @ row no. %d", indexPath.row);
CPPlayerAppDelegate * appDelegate = [[UIApplication sharedApplication] delegate];
RDLogString(@"Conversations: %p. Item count: %d", appDelegate.distribution.conversations, appDelegate.distribution.conversations.count);
//This works
for(CPConversation * x in appDelegate.distribution.conversations){
RDLogString(@"Pointer: %p with name %@", x, x.name);
}
//This fails with aforementioned error
CPConversation * conversationAtCurrentIndex = [appDelegate.distribution.conversations objectAtIndex: indexPath.row];
抱歉格式错误,仍在解决。:)
在此先感谢,尼克