CocoaUser
CocoaUser

Reputation: 1429

Using static var and instance var as the same name in Swift Protocol

using static var and instance var as the variable same name in Swift that will occur compiler error. why?

example:
protocol naming {
   static var firstName: String { get }
   var firstName: String { get }
}

class Employee: NSObject, naming {

   class var firstName: String {
       return "MyName"
   }
   var firstName: String {
      return Employee.firstName
   }
}

Upvotes: 1

Views: 206

Answers (1)

matt
matt

Reputation: 535989

It's a bug. (One of several connected with static variables in protocols.) And in Swift 2.0, it's fixed.

Upvotes: 1

Related Questions