-1

I working on an app with tabs which shows info about a person in a database. In one of my tabs there is a textbox through which a user can search for a new person.

My problem is, how do I refresh all my tabs with the information from the new person?

I make a server call and get all the new info but I just don't know how to refresh the entire app. Any help would be appreciated.

Thank you

user1396737
  • 15
  • 1
  • 6
  • 3
    Why would you refresh all the tabs? Simply refresh the tabs one at a time when the user selects them and you are about to view them. – sch Sep 02 '12 at 19:58

2 Answers2

1

Post a notification when old data is invalidated and post a notification when new data is available. Make your view controllers listen for these notifications. When old data is invalidated, show a loading notification. When new data is available, update your views and clear any loading notification.

Jim
  • 72,985
  • 14
  • 101
  • 108
  • but how do I reload my current view? the search bar is in a subview and I make the server call in there (after the user taps a GO button). How would I refresh the parent view of the search bar with the new info? – user1396737 Sep 02 '12 at 21:43
  • My answer already describes how to do that. – Jim Sep 02 '12 at 21:47
  • I'm pretty new to notification center so please bear with me. In my IBAction method in the subview I posted a notification after I get the new data. I added an observer in the viewdidLoad of the parent view controller but I get a SIGABORT at the post notification, it says unrecognized selector sent to instance 0x84d4450 – user1396737 Sep 02 '12 at 22:29
  • If you've got a problem posting notifications, then post it as a new question, and include the details. – Jim Sep 02 '12 at 22:35
-2
(void)applicationDidBecomeActive:(UIApplication *)application {   \\\your code   }

Reload the data in the above function of the app delegate to refresh the data when ever the app comes to foreground. You can call this function on a button click!

Spudley
  • 166,037
  • 39
  • 233
  • 307
dcprog
  • 135
  • 1
  • 12
  • 1
    Do not call this method manually, that is not a good idea. It is better to do what @sch said in the comments. – SimplyKiwi Sep 02 '12 at 20:30