I have an NSArray with 6 values in it. I'm trying to create 2 additional NSArrays that cycle through the values starting at indexes 2 and 4 respectively.
In other words:
Original NSArray's Index/Values
0 - A
1 - B
2 - C
3 - D
4 - E
5 - F
Desired results:
newArray1
0 - C
1 - D
2 - E
3 - F
4 - A
5 - B
newArray2
0 - E
1 - F
2 - A
3 - B
4 - C
5 - D
Is there an elegant way to loop "back around" through the values after starting midway through the index? I could obviously create 2 loops for each array, but this seems clumsy, and I was hoping for a smarter solution.
In other words:
Original NSArray's Index/Values
0 - A
1 - B
2 - C
3 - D
4 - E
5 - F
Desired results:
newArray1
0 - C
1 - D
2 - E
3 - F
4 - A
5 - B
newArray2
0 - E
1 - F
2 - A
3 - B
4 - C
5 - D
Is there an elegant way to loop "back around" through the values after starting midway through the index? I could obviously create 2 loops for each array, but this seems clumsy, and I was hoping for a smarter solution.
Last edited: