0

I'm trying to use a 2d array in Objective-C but getting an error of Array subscript is not an integer.

NSUInteger grid[15][15];
NSUInteger x,y;

grid[x][y]=1;

I have tried changing from NSUInteger to NSInteger and int.

Can someone please tell me where am I going wrong?

Thanks

1 Answer 1

1

You need to define a value for x and y, or else you're not accessing any index...

NSUInteger grid[15][15];
NSUInteger x=1,y=2;

grid[x][y]=1;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.