Although both Karl and Gregory Higley have the right solutions, including the observation that self () should use the required init, I would like to post a more general example:
class Human { var gender = String() required init() { self.gender = "any" } class func newHuman() -> Human { return self() } } class Man : Human { required init() { super.init() self.gender = "male" } } var someMan = Man.newHuman() println(someMan.gender)
source share