저는 Swift 프로그래밍에서 큰 문제가 있습니다. 부모로부터 자식 클래스의 이름을 얻으려고합니다. 이것은 내가 무엇을 원하는 샘플 예입니다부모로부터 자식 클래스 가져 오기
class Parent {
class func sayHello() {
let nameChildClass = //
println("hi \(nameChildClass)")
}
}
class Mother: Parent {
}
class Father: Parent {
}
Mother.sayHello()
Father.sayHello()
내가 알고있는 몇 가지 다른 방법으로 그에게 할 수 있습니다,하지만 난 정말 그런 식으로 할 필요가있다.
class Parent {
class func sayHello() {
println("base class")
}
}
class Mother: Parent {
override func sayHello() {
println("mother")
}
}
class Father: Parent {
override func sayHello() {
println("father")
}
}
mother = Mother()
father = Father()
mother.sayHello()
father.sayHello()
그냥 많이 감사합니다. 나는 너무 멀지 않았다. – user2724028