How to transfer contents of a variable from one ViewController to another

0

Sorry for my beginner programmer ignorance. I followed the above tips but it gives an error when I make self :

  

Can not assign value of type "MainPageValueController" to type "ViewPasswordController".

TelaAjustesViewController is the Screen 1 of your example and the TelaPrincipalViewController is the 2 .
The value that comes from Screen 1 , is the content of Cor .

import UIKit

class TelaPrincipalViewController: UIViewController { var TransfereCor:TelaAjustesViewController!

override func viewDidLoad()
{
    let v2 = TelaPrincipalViewController ()
    v2.TransfereCor = self
    switch TransfereCor.Cor
    {
    case 0:
        print("Escuro")
        break
    case 1:
        print("Claro")
        break
    case 2:
        print("Daltônico")
        break
    default:
        break
    }
    print(TransfereCor.Cor)
    
asked by anonymous 12.12.2015 / 02:31

1 answer

0

You have to instantiate the previous screen:

var TransfereCor: ScreenAjustesViewController = ViewAdjustController ()

Then you will be able to get the attributes of it through TransfereCor.Cor

    
13.12.2015 / 18:24