My app has two tabs on a main TabViewController.
- The first tab shows a list of the fruits I like.
- The second tab send a request to an api while you type, searching for fruits with the name searched.
If the user clicks on any fruit, I'll show a fruit detail view, where It's possible to like the fruit (if it's already liked, you can unlike).
Now, I'm trying to achieve something like:
- The user searchs for a fruit
- The user likes the fruit
- The user navigates back to the list
- List shows the fruit with the "like" icon highlighted
How can I notify the list which I was before select row, the change of state of the cell (which was unliked and now is liked). How can I notify the OTHER list (in another tab) the same thing?
Thanks guys
EDIT
I'll try to show a real sample! When you go to the appstore and search for GMAIL
Then you go to featured (charts, I don't know in your country), and look for the same app
When you download it in any of those view controllers, at the same time the other controller shows the same status. It is exactly what I want to do.
Simple way is you create one singleton class with array fruit. Example: You have model Fruit:
Every viewcontroler can access it:
Every time 1 fruit has liked or unliked, change property of that fruit, and using NSNotification to notify the change to orther viewcontrollers. Viewcontroller which receive notification will access fruit list of singleton class.