Created
June 15, 2018 08:34
-
-
Save onmyway133/10afdea56cb50b03ea1b0271d9176124 to your computer and use it in GitHub Desktop.
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
public extension StorageAware { | |
func object<T: Codable>(ofType type: T.Type, forKey key: String) throws -> T { | |
return try entry(ofType: type, forKey: key).object | |
} | |
func existsObject<T: Codable>(ofType type: T.Type, forKey key: String) throws -> Bool { | |
do { | |
let _: T = try object(ofType: type, forKey: key) | |
return true | |
} catch { | |
return false | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment