i’ve got some segue created in storyboard. It has some identifier. I configure destinationViewController and assign some object as property of this destinationViewController in method prepareForSegue:sender:. This object is also property of my controller which called segue. In destinationViewController i’ve got BarButtonItem and when i press it, I call other segue and i go back to previous view. And when I’m in this viewController, property with this object which was passed to destinationViewController is equal to nil. Is possible to do something like this? :
- When i’m in
SourceViewControllerwhich hassomePropertyI set property ofDestinationViewController. - When i’m back from
DestinationViewControllermy propertysomePropertyinSourceViewControllerisn’t null – it should be the same as before switching viewController.
It’s possible?
Now i’ve got to pass someObject from A to B and when I’m switching views I have to pass someObject from B to A – the same object.
Thank you for response and help.
Try not using another segue when you return to another view. You should be able to dismiss the current view whether its using a navigation controller or in a modal. As for you needing the same object, keep a reference to the object in controller A when you pass it to controller B. Both controllers will have a reference to the same object so making a change to it in controller B will show up in your object reference in controller A automatically.