我有以下代码:
NSMutableArray *imageArray = [[NSMutableArray alloc] init];
for(int i = 1; i <= 32; i++) {
//NSString *str = [NSString stringWithFormat:@"marker_%i.png", i];
NSString *str = [NSString stringWithFormat:@"wave%i.png", i];
UIImage *img = [UIImage imageNamed:str];
if(img != nil) {
[imageArray addObject:img];
}
}
NSLog(@"imageArray count %i",[imageArray count]);
NSMutableArray *reverseArray = [NSMutableArray arrayWithArray:imageArray];
[[reverseArray reverseObjectEnumerator] allObjects];
[imageArray addObjectsFromArray:reverseArray];
NSLog(@"imageArray count %i",[imageArray count]);
如果我在 iphone 上运行它,我会得到:
2013-05-12 15:21:08.539 RouteApp[5673:907] imageArray count 23
2013-05-12 15:21:08.545 RouteApp[5673:907] imageArray count 46
而如果我在模拟器中运行,我会得到 32 和 64,就像我期望的那样。(就像数字交换一样)
什么会导致这种情况?