Forgoten dynasty
Forgoten dynasty

Reputation: 21

Invoke a method from a different view controller. iPhone SDK

So I have an application with two view controllers one is the main controller that launches when the app launches. This view controller Has two buttons on opens a uiwebview to google.com the other opens that same uiwebview but loads a different page. How can I change the nsurl that is loaded in the other view controller from the original view controller.

Upvotes: 2

Views: 279

Answers (1)

David Foster
David Foster

Reputation: 3834

I'm not completely sure of what you're asking, but generally, if you ever need to communicate between related views (or even views and modal views), most of the time your best bet is to set up a protocol in one view and become a delegate in another by conforming to that protocol. You'll then be able to fire off methods in the first view which your second view can customize.

If you've ever created a table view then you're already loosely familiar with the delegate pattern. For a nice and simple introduction to delegates and protocols, I found this blog post to be one of the best out there.

Upvotes: 1

Related Questions