Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jmerkow

macrumors newbie
Original poster
Jan 20, 2011
17
0
I have a number of objects in a table-view that rotate order after a button is pressed (object 0 becomes object @ end, object 1 becomes object 0 etc). I have this working now by having an index that carries the current index for the top of the queue, and programmatically get the object at 'i' according to the starting index. It is working fine, the order changes as I want. But I was looking at the indexpath class and it occurred to me that I may be able to modify the indexPath to achieve this same goal. And it may come in handy when I want to allow the user to reorder the objects. I looked it up online and it the results are vague. I wanted to see if this method was worth pursuing.


P.S. I do not want to use a picker.
 
Typically you don't modify the IndexPath for a cell directly, you just use it to determine which cell you're going to modify in a TableView delegate method.

I'm not sure what you're doing to make your cell rotation work, but it sounds like all you actually need to do is remove the last cell from the table and datasource, and insert it at the front of the table and datasource. It should even animate well if you use the built in tableview insert/animation methods.
 
The array that the cells are generated from are contained in a aggregated class (a GameState class) inside the view controller. I don't want the viewcontroller to have direct control over the array of objects inside. The GameState keeps track of the currentIndex, and it will return any object inside of it with reference from that currentIndex. i.e. if currentIndex = 4; and you want the object index = 2, it will return the object at index 6.

I suppose I could re-factor so the top is always at 0, but I want the GameState object to keep track of the game, and all the view does is allow interaction and show the game.

But, you answered my question, I do not want to modify the indexpath, typically you move the objects around, which is more or less what I am doing
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.