PDA

View Full Version : Dilemma with button references




rush8946
Apr 19, 2011, 12:17 PM
I am trying to do a battleship game using a 10x10 grid of custom buttons as the game screen.

To do the initial setup for the game I want the user to be able to click on two buttons and use those two buttons as the start and end point for the placement of the ship.

My current issue is that I have no idea how to reference the buttons that lie inbetween the two clicks that will mark the start and end point of the ship placement.

I was wondering if there is a way to reference a button by its tag or object ID without creating a pointer to all 100 of my buttons, or if there was an easy way to create an array of pointers to all 100 of the buttons to make it easy to reference them.

Any ideas would be great as we are stuck at this currently.



chown33
Apr 19, 2011, 12:41 PM
... I was wondering if there is a way to reference a button by its tag...

1. Open the UIView class reference.
2. Search for the term tag.
3. Observe that one of the found items is the method viewWithTag:.