I got the Problem if i try print a var i sometimes get a "Optional("var")" if i try log it or print it to a lable, but else when i dont get it.
See here
ViewController.swift
import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
NSUserDefaults.standardUserDefaults().setObject("notWorking", forKey: "testvar")
NSUserDefaults.standardUserDefaults().synchronize()
println(NSUserDefaults.standardUserDefaults().stringForKey("testvar"))
var test = "working"
println(test)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
Anyone can explain when this "Optional" appears and what its use for? How can i remove it?
Optional
it is appearing if a!
doesn't follow the variable name. Did you ever come to a solution? – Advisory