Distinction in Swift between uppercase “Self” and lowercase “self”

前端 未结 6 1019
心在旅途
心在旅途 2020-12-07 10:53

While playing in a Swift playground I noticed that Self, with capital \"S\", is available along with the lowercase self. Is there any difference be

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-07 11:29

    in protocol & Extension declaration use Self else self

    extension protocolName where Self: UIView 
    {
      func someFunction()
      {
        self.layer.shadowColor = UIColor.red.cgColor
      }
    }
    

提交回复
热议问题