0

I was wondering if there is a way to reload a view controller inside one tab from another tab. This is my scenario

  1. Tab controller has 2 or more tabs
  2. Tab 1 has a view controller which has views created based on some conditions
  3. Tab 2 is a settings page, where some app settings can be changed
  4. How can i reload content inside tab 1 when settings in tab 2 are changed?

IS there something like tab bar -> tab -> view controller -> reload viewDidLoad?

Thanks

Shaggy Frog
  • 27,575
  • 16
  • 91
  • 128
Veeru
  • 4,936
  • 2
  • 43
  • 61
  • @vikingosegundo No need for 'iphone' in the title. That's what the tags are for. I also see no need to delete the "ios" tag, and the "objective-c" tag is misleading since this question is about Apple's implementation of Objective-C, which is Cocoa. It has nothing to do with Objective-C specifically, much in the same way that it has nothing to do with Xcode, which is why I deleted that out of the title, too. – Shaggy Frog Dec 09 '10 at 02:15
  • Hm, i guess our two edits were overlaping. I didnt add iPhone, i just didnt delete it. – vikingosegundo Dec 09 '10 at 02:19
  • and I exchanged xcode with cocoa-touch. i didnt add any else – vikingosegundo Dec 09 '10 at 02:20
  • ok, i added objective-c. – vikingosegundo Dec 09 '10 at 02:22
  • Thanks guys, will remember this in future and add the appropriate tages – Veeru Dec 09 '10 at 02:44

1 Answers1

1

The general way I solve this problem is by having a "Settings"-type object (Model) that is observed by my view controllers. In your case, you'd initialize it in your app delegate, pass it along to the view controllers for Tab 1 and Tab 2, which would then use KVO to observe it. You'd also directly modify it in Tab 2's view controller.

You could also use a NSNotifcation to signal a change in the settings to any view controller that wants to observe it.

Shaggy Frog
  • 27,575
  • 16
  • 91
  • 128
  • Hi shaggy, i think i understand what you meant, just that i am not very sure of how to implement it.. can you point me to some examples? – Veeru Dec 09 '10 at 02:46
  • See http://stackoverflow.com/q/962591/161161 http://stackoverflow.com/q/3720232/161161 http://stackoverflow.com/q/2224285/161161 – Shaggy Frog Dec 09 '10 at 02:59
  • I did find the solution in the threads you have mentioned, thanks shaggy - voting for you :) – Veeru Dec 09 '10 at 10:45