【发布时间】:2014-11-11 10:56:51
【问题描述】:
我有两个可变数组。 “friendsArray”包含一个完整的 os 用户列表,“inviteIndex”包含其中一些用户的索引 (indexPath.row)(使用 uiswitch 按钮进入表列表)。
我将inviteIndex数组填为:
[inviteIndex addObject:[NSNumber numberWithInteger:indexPath.row]];
为了只有选定的用户,我这样做:
for (int i =0; i< [inviteIndex count]; i++) {
MyElement *friend =[friendsArray objectAtIndex:[inviteIndex objectAtIndex:i] ];
NSLog(@"BUTTON PRESSED %@", friend.friendId);
}
但应用程序崩溃并显示消息:
[__NSArrayM objectAtIndex:]: index 400931632 beyond bounds [0 .. 4]'
我用过MyElement *friend =[friendsArray objectAtIndex:(NSInteger)[inviteIndex objectAtIndex:i] ];
结果相同。
有什么帮助吗? 提前致谢。
【问题讨论】:
标签: ios nsmutablearray nsindexpath