0

I have a view with a textfield and a button (to navigate to the next view).

When I click the button a new view is loaded which has UITableView and is populated from a nsmutablearray. I am selecting multiple rows here, which I am saving in a variable when i click on the button, clicking on this button also takes me back to my first view

Now what I want to do it that this selected data from the second view uitableview or from the variable where i save it should be displayed in the textfield in the first view when I go back.

I don't know how to do this. I am new to xcode. Can someone please help me? Thank you.

Sanjyot Shah
  • 225
  • 1
  • 5
  • 17

1 Answers1

0

The problem with your current approach is that you store the selected data on the view that you are removing from the memory when turning back to the first view. You should try to follow a kind of MVC (Model View Controller) pattern.

To keep things short: centralize your data in one place in your app. Like for instance on a Model class on the RootViewController and access the data from there. When the user selects a few rows then write back to the model which ones were selected and return to the previous view. Then, when back at the previous view, read what elements were selected from this centralized model and show them back to the user.

polyclick
  • 2,704
  • 4
  • 32
  • 58