You have a wrong index, a is the number of point in the array, you have start from (a - 1) to 0([xScreenLocations objectAtIndex:(a - 1)]
instead of [xScreenLocations objectAtIndex:a]
), you also have to correct you condition in the while loop (a > 0
) instead of (a >= 0
).
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
int a = (int)[xScreenLocations count];
while (a > 0)
{
NSNumber *currentXNumber = [xScreenLocations objectAtIndex:(a - 1)];
float currentXInt = currentXNumber.floatValue;
NSNumber *currentYNumber = [yScreenLocations objectAtIndex:(a - 1)];
float currentYInt = currentYNumber.floatValue;
NSLog(@"%.1f %.1f",currentXInt,currentYInt);
a--;
}
}