Created
December 21, 2015 07:53
-
-
Save externvoid/e1c7121439b63b3fa20c to your computer and use it in GitHub Desktop.
nilが返るかもしれないメソッドの取り扱い
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // nilが返るかもしれないメソッドの取り扱い | |
| //let obj6 = NSUserDefaults.standardUserDefaults().objectForKey("user data") | |
| var obj6: AnyObject? = nil | |
| print(obj6) | |
| var obj5 = obj6 as? [String: Int] ?? [String: Int]() | |
| //var obj5: [String: Int] = obj! as [String: Int] ?? [String: Int]() | |
| obj5["hp"] = 3 | |
| print(obj5) // ["hp": 3] | |
| print(obj5.dynamicType) // Dictionary<String, Int> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment