Created
July 26, 2015 08:17
-
-
Save RoyalIcing/2f8a2d333f5c2f59e4dc to your computer and use it in GitHub Desktop.
Parse & JSON API
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
protocol ValueStorable { | |
subscript(key: String) -> AnyObject? { get set } | |
} | |
internal protocol ValueStorableUpdater { | |
init?(fromStorable storable: ValueStorable) | |
func updateStorable(inout storable: ValueStorable) | |
} | |
extension PFObject { | |
private struct ParseStorable: ValueStorable { | |
let parseObject: PFObject | |
subscript(key: String) -> AnyObject? { | |
get { | |
return parseObject[key] | |
} | |
set { | |
parseObject[key] = newValue | |
} | |
} | |
} | |
final var storable: ValueStorable { | |
return ParseStorable(parseObject: self) | |
} | |
} | |
struct RecordJSON: ValueStorable { | |
typealias Dictionary = [String: AnyObject] | |
var dictionary: Dictionary | |
subscript(key: String) -> AnyObject? { | |
get { | |
return dictionary[key] | |
} | |
set { | |
dictionary[key] = newValue | |
} | |
} | |
} | |
extension RecordJSON { | |
init() { | |
self.init(dictionary: Dictionary()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment