Dilemma with button references

Discussion in 'iOS Programming' started by rush8946, Apr 19, 2011.

  1. rush8946 macrumors newbie

    Apr 19, 2011
    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.
  2. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset
    1. Open the UIView class reference.
    2. Search for the term tag.
    3. Observe that one of the found items is the method viewWithTag:.

Share This Page