0
I have the following problem: I have the following code
var myGlobal : String
func nomeDaFuncao () {
// Preciso acessar a global
myGlobal = "fff"
}
How can I access the global within a function or an action ? Thank you
0
I have the following problem: I have the following code
var myGlobal : String
func nomeDaFuncao () {
// Preciso acessar a global
myGlobal = "fff"
}
How can I access the global within a function or an action ? Thank you
2
You can use the self
if using the attribute in the same class
self.myGlobal = "VALOR"
Example:
class ViewController: UIViewController {
var myGlobal : String?
override func viewDidLoad() {
super.viewDidLoad()
self.myGlobal = "Teste"
}
}
Remember to use ?
for non-mandatory attributes and !
for mandatory taxes
Browser other questions tagged ios swift
You are not signed in. Login or sign up in order to post.