对于循环目标C.

The*_*Man 4 iphone cocoa-touch objective-c ios ios5

为什么我会在这段代码中得到这个?

ids = 0;
for (NSString *s in golferThreeIconCounter) {
    ids++;
    NSLog(@"%i", ids);
}
Run Code Online (Sandbox Code Playgroud)

结果

2012-05-24 16:30:35.194 Dot Golf Scoring[673:f803] 4
2012-05-24 16:30:35.196 Dot Golf Scoring[673:f803] 8
2012-05-24 16:30:35.196 Dot Golf Scoring[673:f803] 12
2012-05-24 16:30:35.197 Dot Golf Scoring[673:f803] 16
2012-05-24 16:30:35.197 Dot Golf Scoring[673:f803] 20
2012-05-24 16:30:35.198 Dot Golf Scoring[673:f803] 24
2012-05-24 16:30:35.199 Dot Golf Scoring[673:f803] 28
2012-05-24 16:30:35.199 Dot Golf Scoring[673:f803] 32
2012-05-24 16:30:35.200 Dot Golf Scoring[673:f803] 36
2012-05-24 16:30:35.200 Dot Golf Scoring[673:f803] 40
2012-05-24 16:30:35.201 Dot Golf Scoring[673:f803] 44
2012-05-24 16:30:35.201 Dot Golf Scoring[673:f803] 48
2012-05-24 16:30:35.202 Dot Golf Scoring[673:f803] 52
2012-05-24 16:30:35.202 Dot Golf Scoring[673:f803] 56
2012-05-24 16:30:35.203 Dot Golf Scoring[673:f803] 60
Run Code Online (Sandbox Code Playgroud)

对我来说,为什么id上升4次而不是一次就完全没有意义......

das*_*ght 14

声明int时,不要添加*:它不是<id>类型.你有什么是指针int; 在32位平台上,它增加4.

int ids = 0;
Run Code Online (Sandbox Code Playgroud)