EveryBody..
i want to create one 8*8 dimensional array in objective c..
(
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
)
like that..
And also use as one of the object can moved in it..
Like want to move
MOVE_ARRAY = array([0, 0], [0, 2])
And also check the array’s any position like 5*6 or 4*3 any..
So, Can any one help me about how to initialize , and how to use in code ?
Thanks.
In Objective-C:
(
arrayis an instance variable, that has to be added to your header file and released in youdeallocmethod)To retrieve a value at a certain position you could write a method like this:
=== UPDATE ===
To remove an object you could do this:
You have to be careful though, because removing objects will change the structure of the array (e.g. the row where you removed an object will have only 7 items after the removal. So you might want to think about leaving the structure intact and set the values that you want to delete to a value that you normally don’t use: