Skip to content

Instantly share code, notes, and snippets.

@alexkent
Created August 1, 2014 14:59
Show Gist options
  • Save alexkent/65c0899c5790ca2fef47 to your computer and use it in GitHub Desktop.
Save alexkent/65c0899c5790ca2fef47 to your computer and use it in GitHub Desktop.
import Foundation
public class Thing: NSObject {
public enum State {
case yes, no, maybe
}
public var state:State
internal init() {
self.state = State.maybe
}
}
extension Thing {
public convenience init(json:[String:AnyObject]) {
self.init()
self.populateFromJson(json)
}
public func populateFromJson(json:[String:AnyObject]) {
// do stuff
}
}
public class ThingModelB: Thing {
public var foo:String
public init(foo:String) {
self.foo = foo
}
}
extension ThingModelB {
public convenience init(json:[String:AnyObject]) {
if json["foo"] {
let jsonFoo = json["uuid"]! as String
self.init(foo: jsonFoo)
}
else {
// how about, don't f'king init ?!
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment