如果在类扩展中声明了任何方法是否静态,我会感到困惑

时间:2018-08-28 09:57:25

标签: ios swift swift-protocols swift-extensions swift-class

class Test: UIViewController{

    func abc() {
        print("This is ABC")
    }
}

extension Test {
    func def(){
        print("This is DEF")
     }
}

我的问题是

  1. 两种声明的方法之间有什么区别?
  2. 方法是否是静态方法?
  3. 扩展类以使用协议会影响内存管理吗?

1 个答案:

答案 0 :(得分:0)

what is the difference between both the methods declared?

没有,除了两件事

  1. 一个打印ABC,另一个打印DEF,它们具有不同的名称
  2. 您将无法覆盖扩展名中的方法

Is method def a static method?

不,为此,您应该说static

extending class to use protocols effects memory management?

不是