Created
August 1, 2014 14:59
-
-
Save alexkent/65c0899c5790ca2fef47 to your computer and use it in GitHub Desktop.
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 | |
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