You declared extern variable (privat) in the @interface file and after that you declared it again in while loop. There is also mistake in while loop, it should be for:
for(int x1 = 0; x1 < 100; X1++)
the last X1 should be lowercase it makes a difference in Objective c. You should use for loop, while loop works like that:
while(CONDITION)
{
//logic here
}
//for example
while(x1 < 100)
{
//logic here
}
You don't have to declare
extern int x1;
the better is just
int x1;