I found really strange behaviour when looping through NSString array. The thing is it happens only in iOS 32bit environment, but on 64bit works as expected.
here is the code I run:
static NSString * const HexColors[3] = {
@"FFFFFF",
@"FF0000",
@"000000"};
static NSString * const ColorDescription[3] = {
@"white",
@"red",
@"black"};
in implementation file I loop as following
- (void)loop {
NSInteger i = 0;
while (HexColors[i]) {
NSLog(@"%@", HexColors[i]);
i++;
}
}
The result I get:
2014-04-25 09:57:45.374 loopApp[587:60b] FFFFFF
2014-04-25 09:57:45.375 loopApp[587:60b] FF0000
2014-04-25 09:57:45.376 loopApp[587:60b] 000000
2014-04-25 09:57:45.376 loopApp[587:60b] white
2014-04-25 09:57:45.377 loopApp[587:60b] red
2014-04-25 09:57:45.377 loopApp[587:60b] black
And then app throws EXC_BAD_ACCESS on NSLog line
I could use "for" loop but this is not the case
Any idea why it happen? Is it the clang issue?
i =3; while (i){ i--;NSLog(@"%@", HexColors[i]);}