1

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
   }
}

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.