Reputation: 860
I tried to implement this method from the documentation by Apple.
- (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath
But my code did not work until I implemented this method:
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
I am absolutely clueless about why it didn't work and why it works now.
Upvotes: 1
Views: 734
Reputation: 1229
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
This is data source method to move a row at a specific location in the table view to another location. When user presses the reorder control, this method will get called and in which you have to rearrange the data, so that table view will get redrawn based on the reordered data at the fromIndexpath and toIndexPath.
Upvotes: 2
Reputation: 15566
- (void)moveRowAtIndexPath:(NSIndexPath *)indexPath
toIndexPath:(NSIndexPath *)newIndexPath
Is for UITableView
subclasses
- (void)tableView:(UITableView *)tableView
moveRowAtIndexPath:(NSIndexPath *)fromIndexPath
toIndexPath:(NSIndexPath *)toIndexPath
Is for data sources. Obviously you are not using a subclass and are rather implementing delegate/datasource methods. This makes sense though. If you are a subclass you can only have one possible table view. If you are a datasource you can have as many as you want (you could be the datasource for 100 table views). This way you would need to know which table view you are dealing with, hence the extra parameter.
Upvotes: 1