Title: Retrieving original row index
Tags: uitableview;swift
Question: I am using a standard iOS Table View in Swift, and am now working on removing rows. It works for the most part, but the problem is retrieving the row's original index.
For instance, take this example data
---- Row 1 -----
---- Row 2 -----
---- Row 3 -----
---- Row 4 -----
If i remove row 3, then get the index of row 4 using:
indexPath.row
It now returns 3, instead of 4. This screws up my logic, as each row has data associated with it, which have unique id's, so i need to be able to cherry pick the data in my NSDictionary that is associated with row 4 (for example), so i can update my web api to inform it to remove data with id of x from the database, then delete that row also, when the time comes (and after removing a row before it).
Is there any way to retrieve the row's original row index, prior to it's new index after deleting a row? I'm presuming I am missing something big here, as this functionality is essential.
Thanks in advance.
Comment: Shouldn't really rely on those row #'s. But if you want why not make a model object that has a property for `rowID` or something, and then just set that when you construct your data source, and then use it in your logic.

Comment: Yeah, that is what I was going to do. Just hoped there was an inbuilt variable i could retrieve as part of the cell, since this is not a rare use case. Oh well :) I guess one could extend some classes to make this a reality, but it's more work than doing what you suggested. Cheers



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2014:00:12/19/14', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<uitableview><swift>', 'Title': 'Retrieving original row index', 'ViewCount': 34, 'id': 27572513, 'user_AboutMe': '<p>Languages: C, C++, Objective-C, Swift, Java, Lua, Json</p>\n', 'user_AccountId': 1363220.0, 'user_DisplayName': 'PersuitOfPerfection', 'user_Reputation': 999.0, 'user_Views': 117.0, 'user_id': 1300186.0}}