我现在拥有的是:
NSUInteger rows = 50; // once again, some random, runtime number
@try {
for (int i=1; i< [accountArray count]; i++) {
AccountBalance *tempAb = [accountArray objectAtIndex:i];
NSLog(@"CurrentI%d",i);
if ([allAccountType count] <= 0)
{
[allAccountType addObject:tempAb.getCurrency];
}
else
{
if ([allAccountType[i] containsObject:tempAb.getCurrency])
{
NSMutableArray * existingAccount = [NSMutableArray arrayWithCapacity: columns];
[existingAccount addObject: tempAb.getCurrency];
[allAccountType addObject: existingAccount];
}
else{
NSMutableArray * nonExistingAccount = [NSMutableArray arrayWithCapacity: columns];
[allAccountType addObject:nonExistingAccount];
}
}
}
}
@catch (NSException *exception) {
NSLog(@"%@", exception.reason);
}
@finally {
NSLog(@"Error");
}
结果应该是这样的: allAccountType [] = [USD [account1,account2,account3],EUR [Account1,account2,account3]];
我在这里尝试做的是拥有一个包含所有货币帐户的数组,以及一个包含各自货币帐户的多个数组。
我现在的错误是:
*** -[__NSArrayM objectAtIndexedSubscript:]: index 2 beyond bounds [0 .. 0]