importFoundation
classmytest {
var_name:NSString?="test"
//构造函数
init(){
println(_name)
}
init(name:String){
_name= name
}
funcsayname(){
println("my name\(_name)")
}
//类方法
classfuncsaystaticname(){
("calss my name test")
}
}
classutest:mytest{
//重写方法
overridefuncsayname() {
("utest name)
}
}
extensionutest{
funcextensiontest(){
("extensiontest name)
}
}
/*
//调用静态访求
mytest.saystaticname()
var mytest3 = mytest(name: "swift");
mytest3.sayname()
var utest1 = utest(name: "utest")
utest1.sayname()
utest1.extensiontest()
*/
原文链接:https://www.f2er.com/swift/326542.html