Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if NSUserDefaults key exists

Tags:

In my application, I am saving a key using this code:

func saveKey(){
        var xmineSpillere = mineSpillere
        var defaults = NSUserDefaults.standardUserDefaults()
        defaults.setObject(xmineSpillere, forKey: "YourKey")
    }

But how can I check if the key exists? I want the code something like this:

if key("YourKey") exists {
    println("key exists")
}
else {
    println("does not exist")
}

How can I do something like this in Swift?