Display NSArray in disorderly fashion

Discussion in 'iOS Programming' started by moonman239, Jul 29, 2014.

  1. moonman239 macrumors 68000

    Joined:
    Mar 27, 2009
    #1
    I have a client. This client wants me to show her an app that takes an array and arranges it in a way that is out of order.

    Maybe I could use NSSet.
     
  2. JohnsonK macrumors regular

    Joined:
    Mar 6, 2014
    #2
    You have an array, you want to show its contents out of order.

    To achieve this you can shuffle your array, to do so you can use in a loop:
    Code:
    arc4random_uniform()
    and
    Code:
    exchangeObjectAtIndex:withObjectAtIndex:
    Having your array shuffled, you can then iterate through your array like you normally would, displaying each object.
     
  3. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #3
    NSSet isn't necessarily disorderly. The order is unspecified and may change at any time, so it might be disorderly, but it's not necessarily so.
     

Share This Page