Skip to content

Instantly share code, notes, and snippets.

@3lvis
Created November 8, 2015 09:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 3lvis/9e9cc1f115fe0b7c4499 to your computer and use it in GitHub Desktop.
Save 3lvis/9e9cc1f115fe0b7c4499 to your computer and use it in GitHub Desktop.
Syncable
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