views:

19

answers:

1

Hi,

I have an iPhone application that has a user preference page where the user can rearrange the uitableview rows just like the iPhone built in weather forecast app's settings page. Now my problem is after the user in done with rearranging, I need to save the data in database in rearranged order. But I'm not been able to read the data from the uitableview.

How can I read the rearranged data from the uitableview?

Looking for your valuable response

Thanks in advance

Joy

+2  A: 

You do not read the rearraged order at the end of the editing, UITableView tells it's dataSource what is being changed while the editing takes place. It does so using the messages:

- (void)tableView:(UITableView *)tableView
         commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
         forRowAtIndexPath:(NSIndexPath *)indexPath;

- (void)tableView:(UITableView *)tableView
         moveRowAtIndexPath:(NSIndexPath *)fromIndexPath
         toIndexPath:(NSIndexPath *)toIndexPath;

You would implement your datasource, so that it records this changes and can store them when the editing is finished.

Another not recommend way would be the to enumerate your tableView cell's using

- (UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath;

Then figure out with dataEntity is represented by this cell, and reconstruct the underlying data.

The last approach is only for completeness, please use the first.

tonklon