swift 类的动态扩展

前端之家收集整理的这篇文章主要介绍了swift 类的动态扩展前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。



import Foundation


class Student{
    func sayHi()
    {
         print("student say hi")
    }

}

extension Student{
    func sayextensionFunc(){
        print("extension func")
    }
}

class Persion:Student{
    
    var _name:String
    
    init(name:String) {
        self._name = name
    }
    
    override func sayHi() {
        super.sayHi()
        print("say \(self._name)")
    }
}

var persion = Persion(name: "yihong")
persion.sayHi()
persion.sayextensionFunc()
原文链接:https://www.f2er.com/swift/325912.html

猜你在找的Swift相关文章