Repeating task

Discussion in 'iOS Programming' started by lynkynpark86, Jun 18, 2011.

  1. lynkynpark86 macrumors 6502

    #1
    I have an array with about 30 items. I also have a method that creates a file in a directory with the name based off a string. I need to repeat the method several times, once for each item of the array, until it's done. This is basically what is is (I realize createDirectory won't work, it's just to make the example shorter):
    Code:
    - (void)theMethod {
    
        createDirectoryWithTitle:%@;
    
    }
    
    How could I get that to work, once for each item in the array, loading the array item to the %@? Ideas? Please?
     
  2. MorphingDragon, Jun 18, 2011
    Last edited: Jun 18, 2011

    MorphingDragon macrumors 603

    MorphingDragon

    Joined:
    Mar 27, 2009
    Location:
    The World Inbetween
    #2
    You need to go back and learn your programming basics if you don't know how to access each item in an array. You use a type of loop.
     
  3. ViviUO macrumors 6502

    Joined:
    Jul 4, 2009
    #3
    I think a for loop will suit you nicely.

    Here is a basic overview: for loops
     
  4. forum user macrumors regular

    Joined:
    Aug 28, 2008
    #4
    FastEnumeration

    Better that remembering the syntax of the classic for loop. Even if you need a counter, a friendly counter++ will do the job nicely.

    - Olaf
     

Share This Page