Created
November 8, 2015 09:53
-
-
Save 3lvis/9e9cc1f115fe0b7c4499 to your computer and use it in GitHub Desktop.
Syncable
This file contains 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
import Foundation | |
protocol Syncable { | |
static func sync(dictionary: [Dictionary<String, AnyObject>]) | |
} | |
extension Syncable { | |
static func sync(dictionary: [Dictionary<String, AnyObject>]) { | |
} | |
} | |
protocol UserProtocol { | |
var remoteID: String { get set } | |
var name: String? { get set } | |
var date: NSDate? { get set } | |
} | |
struct User: UserProtocol, Syncable { | |
var remoteID: String | |
var name: String? | |
var date: NSDate? | |
init(remoteID: String) { | |
self.remoteID = remoteID | |
} | |
} | |
let json: [Dictionary<String, AnyObject>] = [ | |
["remoteID": "1", "name": "Elvis"], | |
["remoteID": "2", "name": "Luciana"] | |
] | |
User.sync(json) | |
// let users = User.all() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment