0

How can I bring a variable from a View controller to the back one? (i.e. from B view controller to A view controller?)

I have a switch value that i set on View controller B and I need to access this data also from the back view controller the A.

  • -(void) switchChanged:(id)sender{ UISwitch *switchController = sender; if (tappulsante == 3){ if (switchController.on==YES && switchController.tag == 0) { self.provina = 1; NSLog(@"prodottoscelto: %i", provina); } This is the code and I have to bring the variable "provina" to the previous view controller. – Amerigo Ievoli Mar 07 '16 at 18:31
  • 4
    Possible duplicate of [Passing Data between View Controllers](http://stackoverflow.com/questions/5210535/passing-data-between-view-controllers) – JAL Mar 07 '16 at 18:31
  • Possible duplicate of [How to pass prepareForSegue: an object](http://stackoverflow.com/questions/7864371/how-to-pass-prepareforsegue-an-object) – Stefan Mar 07 '16 at 21:06

1 Answers1

0

You can use the prepareForSegue method to pass parameters from one view to another.

Stack overflow already has an answer for this: How to pass prepareForSegue: an object

Community
  • 1
  • 1
Stefan
  • 5,203
  • 8
  • 27
  • 51