我想了解如何在 2D 中使用 for-each 语句NSMutableArray
。我的代码如下。它在第三个(最里面的)for 语句引发异常。例外是:
"Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber count]: unrecognized selector sent to instance"
我的代码:
NSMutableArray* subTryingSet=[NSMutableArray arrayWithArray:[self genSetNumbers:arrRandoms withSize:4]];
for (NSMutableArray* oneRow in subTryingSet) {
for (NSMutableArray* w in oneRow) {
for (int i=0;i<w.count;i++) {
NSLog(@"%d", [[w objectAtIndex:i] intValue]);
}
}
}