Help with random selection

Discussion in 'iOS Programming' started by DVNO, Jun 7, 2009.

  1. DVNO macrumors newbie

    Jan 20, 2009
    Hi, I want to know how I would be able to have my app choose a selection of text from a list of multiple selections when a button was pressed. In example, a random tip for an app every time a "give me a tip" button was pressed.
  2. Bevz macrumors 6502a

    Oct 23, 2007
    Rand() ?
  3. DVNO thread starter macrumors newbie

    Jan 20, 2009
    Thanks, I'm very new to programming in a C based language. I will look into this. How would I be able to set this up with a list of tips or something of the sort? I want to have a button you can press to bring up a tip. If you have any information pleasse let me know.
  4. johnnyjibbs macrumors 68030


    Sep 18, 2003
    London, UK
    Once you have a random key, you could have a database, an array, a list of files or whatever with a number (say 1-50) identifying each piece of tip text that you draw upon when the button is pressed.

    The random number therefore determines which decision is made.

    To create the button that displays the view is easy using UIKit, which I hope you are familiar with. If not, you should read up on views etc using Appe's documentation.

    The tip could be displayed in a label in a modal view, or perhaps in a UIAlertView. The opportunities are endless... ;)

Share This Page