Swift subclassing, recursion, and super casting -


i'm trying define swift class has recursive function returns names of variables in class. works printing it's variables, when use i'll using base class models, , may have multiple layers of inheritance. want method return array of variable names on current instance, names of variables on super classes, until reach base cool class.

class cool:nsobject {            func dostuff() -> [string] {         var values = [string]()         let mirrortypes = reflect(self)         in 0 ..< mirrortypes.count {             let (name, type) = mirrortypes[i]             if let supercool = super as! cool while name == "super" {                 values += supercool.dostuff()                }         }         return values     }    } 

the problem in:

if let supercool = super as! cool while name == "super" { 

it causes expected '.' or '[' after super compiler error.


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -