Jacob
Jacob

Reputation: 1310

Save UITableView's selected row

I have two UITableViews. I want to know how to "save" the selected row in the first table view to be able to use that number as a index for showing that specific index in my other table view. It uses a plist to store an array with arrays with dictionaries.

Here is what I am trying to use now:

mycontroller.selectedIndexPath = indexPath.row;

selectedIndexPath is a NSUInteger. But is doesn't really work. Any suggestions for a solution? Thanks.

Upvotes: 0

Views: 567

Answers (1)

Subbu
Subbu

Reputation: 2101

Code as follows :-

First of all ,you are doing a wrong thing in your question , it should be as follows

myController.selectedIndexpath.row = indexpath.row

first option :- To store the row of selectedIndexPath , you can store it as userDefaults

[[NSUserDefaults standardUserDefaults] setInteger:indexPath.row forKey:@"selectedRow"];

And use it in the SecondTableView

index =  [[NSUserDefaults standardUserDefaults] integerForKey:@"selectedRow"];

second option:-

use `@property`

Upvotes: 1

Related Questions