I use Storyboard create a view controller,but with the code instantiation,then pass the value to the controller.
I know it will be called "initWithCoder:
", but in the method the property is nil.
I get the property values form somewhere?
Asked
Active
Viewed 35 times
0
-
1Pleas show your code. It isn't clear what you are asking. – Paulw11 Nov 10 '15 at 08:33
-
access the property in the viewWillAppear: function – Constantin Saulenco Nov 10 '15 at 09:09
-
https://www.dropbox.com/s/o3qdmb6ktuayl13/CoderDemo.zip?dl=0 This is an example of address – RuiK Nov 10 '15 at 09:10
2 Answers
0
If you are creating your view controller through a storyboard segue, use the source view controller's prepareForSegue()
method, as explained in this answer to a similar question.

Community
- 1
- 1

Nicolas Miari
- 16,006
- 8
- 81
- 189
-
-
https://www.dropbox.com/s/o3qdmb6ktuayl13/CoderDemo.zip?dl=0 This is an example of address – RuiK Nov 10 '15 at 09:13
0
Let's say you have viewControllers: A (root) and B (presenting). You need to use prepareForSegue
method from A viewController:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if let bView = segue.destinationViewController as? BViewController{
bView.yourDataProperty = dataItem
}
}
}
Make sure your sender is presenting BViewController
in Storyboard. Otherwise this method won't be called

Timur Mustafaev
- 4,869
- 9
- 63
- 109
-
https://www.dropbox.com/s/o3qdmb6ktuayl13/CoderDemo.zip?dl=0 This is an example of address – RuiK Nov 10 '15 at 09:13