I need some sort of queue system in my game, trying to figure out the right way to go.
If I have a NSMutableArray, called customerQueue, and add 4 objects to that array. There will now be objects add index, [0],[1],[2],[3].
Then I wanna deal with customer number 1, that is index [0] in customerQueue. Since the customer is no longer in the queue, I can remove it from the array. So far so good.
However, now I want the remaining 3 objects in the queue to take a “step forward”, like
object at index [1] moves to index [0] and object at index [2] goes to [1]…,you get the point.
I can´t find a method in NSMutableArray.h for this, so, can it be done this way? Any similar approach?
A category for NSMutableArray that turns it into a queue is explained here.
In your case all you really need to do is to remove the first object: