Something is wrong, this code
if ([g count] >= 1) {
NSLog(@"%@", [g objectAtIndex:1]);
}
Keeps generating this error
reason: '*** -[__NSArrayI objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
Unless I’m going crazy, this shouldn’t happen, right?
The code is NOT multithreaded at this point and I’m working off a simple array. If I NSLog the g.count, i get a value of 1.
EDIT: I have also tried
if ([g count] > 0) {
NSLog(@"%@", [g objectAtIndex:1]);
}
and get the same error.
When
countis 1, it means that you can use index zero. Index of1is not valid.In general, only indexes from zero to
count-1, inclusive, are valid.