![]() This means you can either accept the optionality, or typecast it to a non-optional type and use the nil coalescing operator to handle missing values. When retrieving objects, the result is optional. Let useTouchID = defaults.bool(forKey: "UseTouchID") With that in mind, you can read values back like this: let age = defaults.integer(forKey: "Age") ![]() object(forKey:) returns AnyObject? so you need to conditionally typecast it to your data type.double(forKey:) returns a double if the key existed, or 0.0 if not.float(forKey:) returns a float if the key existed, or 0.0 if not.bool(forKey:) returns a boolean if the key existed, or false if not. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |