Using arc4random, to randomize views?

Discussion in 'iOS Development' started by Death•Magnetic, Jun 24, 2009.

  1. Death•Magnetic

    Death•Magnetic New Member

    Joined:
    Jun 3, 2009
    Messages:
    4
    Likes Received:
    0
    HeLlo all! I have a (hopefully easy) question for y'alL!

    well I am making an app, and I would like the very first view to be different everytime, the whole view doesn't have to be different, but a button on the view does... I figured just having the views different would be easier, but I could (probably am) be wrong...

    What I was thinking of doing:

    Using the arc4random (which I am not entirely sure how to use) to generate a random number, that corresponds to a certain view, so its random every time, the only problem is... well, I am not sure how to do it... I have searched it @ dev.apple.com and no luck in terms of finding what I need, any help would be gr8!
  2. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    If you want a random number..

    Code:
    srand(time(NULL));
    int randomint = random();
    srand() is a seed so that the random number is not the same every time.
  3. Pelaez-1

    Pelaez-1 New Member

    Joined:
    May 5, 2008
    Messages:
    822
    Likes Received:
    0
    Device:
    iPhone
    So you are going to put a different view instead of just modifying part of it?...

    People use IB too much...
  4. Death•Magnetic

    Death•Magnetic New Member

    Joined:
    Jun 3, 2009
    Messages:
    4
    Likes Received:
    0
    IB is easier for me, so I figured I would do the easiest way...

    If you have any suggestions outside interface builder, please share!
  5. Pelaez-1

    Pelaez-1 New Member

    Joined:
    May 5, 2008
    Messages:
    822
    Likes Received:
    0
    Device:
    iPhone
    Well, IB is good for static views, if you have a view that mutates, you can code the UI.

    I think that people rely way too much on IB. I don't use it mostly because I don't have a Mac, but even when I use my dad's Mac, I code my UIs.

    You can also mix IB with code, so a part of your View can be static, and when loaded, you can add or edit things.
  6. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    I set my navigation controllers and tab bar controllers up in IB, from there on in, it was all coded UI.
  7. spoonforknife

    spoonforknife Retired Moderator

    Joined:
    Nov 15, 2007
    Messages:
    6,896
    Likes Received:
    317
    IB always screws up for me, so I code my UIs.
  8. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    Very true, IB can get confusing at times. I'm *probably* going to start to just code the WHOLE UI.
  9. NolesFans

    NolesFans New Member

    Joined:
    Sep 23, 2008
    Messages:
    404
    Likes Received:
    0
    Device:
    iPod touch
    It always work best to code your own then you able to learn and see what it can do without looking in IB to find exactly you want.
  10. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    Anyway better keep this on topic.

Share This Page