I have some variables in ViewController.swift file which is located in root of the application (default location) and I want to use them in KeyboardViewController.swift file which is located in custom keyboard target
how can I access those variables?
for being more clear I want to access the variables I have declared in ViewController.swift from a view controller in a target.
you can see the sample code I have problem with here:
ViewController.swift
import UIKit
public var globalVar = "defaultColor"
class ViewController: UIViewController {
@IBAction func buttonA(sender: UIButton) {
globalVar = "ColorA"
}
@IBAction func buttonB(sender: UIButton) {
globalVar = "ColorB"
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
KeyboardViewController.swift
import UIKit
class KeyboardViewController: UIInputViewController {
override func updateViewConstraints() {
super.updateViewConstraints()
// Add custom view sizing constraints here
}
override func viewDidLoad() {
super.viewDidLoad()
if (globalVar == "defaultColor" /* The error is here it says use of unresolverd identifier 'globalVar' */) {
} else if (globalVar == "ColorA") {
} else if (globalVar == "ColorB") {
}
}
}