I have a cycle:

NSMutableArray *mutableArray = [[NSMutableArray alloc] init]; for (int min = 0; min < 6; min++) for (int sec = 0; sec < 60; sec++) { [mutableArray addObject:[NSString stringWithFormat:@"%d : %d",min, sec]]; } self.time = [NSArray arrayWithArray:mutableArray]; 

and there is a display of each element. How to make every fifth displayed? For example, 0: 0, 0: 5, 0:10 , and so on.

    1 answer 1

    I do not know what you have and how, but it can be like this:

     NSMutableArray *mutableArray = [[NSMutableArray alloc] init]; for (int min = 0; min < 6; min++) { for (int sec = 0; sec < 60; sec+=5) { [mutableArray addObject:[NSString stringWithFormat:@"%d : %d", min, sec]]; } self.time = [NSArray arrayWithArray:mutableArray]; } 
    • yes, sure, thanks!) - David Kakaladze
    • @DavidKakaladze happens) - dirkgntly
    • by the way, why do you have nested for not in {}? - dirkgntly
    • Well, he already works - David Kakaladze
    • and the line self.time = [NSArray arrayWithArray: mutableArray]; do you refer to for or is it out of cycle? - dirkgntly