質問

Is it possible to communicate with a viewcontroller after a segue switched to another viewcontroller? I want to know, because I need data from a viewcontroller passed on to the next viewcontroller,

but I just can't figure out how to get data from one viewcontroller to another, as they have no unique names or something which I can use to communicate with.

So can someone tell me: If it is possible to communicate between viewcontrollers, and if possible, how?

役に立ちましたか?

解決

I have searched for tutorials about making a MVC based iPhone app, but without success

Goto ITunesU and look for Paul Hegartys "iPad and iPhone Application DEvelopment" from stanford university

very good!

他のヒント

Usually you do it the other way around, pushing values from the source to the destination. If you implement prepareForSegue in the view controller that is going to be segue'd out, you can use

[segue destinationViewController]

to get a reference to the destination view controller. Then you can set any values in that controller that are needed using properties on that controller before it segues in.

try the views presentingViewController property.

A typical OOP pattern is to create yet another object, a Model object (MVC paradigm), connect all the view controllers that need to communicate with this Model object, and pass any shared state or variables by setting and getting properties in this Model object. A common shortcut for very small apps is to use the App Delegate as a Model object, as any other controller can get a reference to the app delegate. But this shortcut is not very extensible to larger or reusable code.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top