4

Here is my sample code which brings my questions:

protocol Decodable {
  init?(json: [String: AnyObject]) // remove this line will solve the problem
}

extension UIFont: Decodable { // remove `Decodable` will also solve the problem
  convenience init?(json: [String: AnyObject]) { // Error: Initialiser requirement 'init(json:)' can only be satisfied by a `required` initializer in the definition of non-final class 'UIFont'
    self.init(name: "whatever", size: 10)
  }
}

The code above tested with Xcode 7.3 & Swift 2.2

Anyone have an idea about this error, why there is somehow a relation with protocol defined method ?

swiftBoy
  • 35,607
  • 26
  • 136
  • 135
user3379127
  • 271
  • 2
  • 6

0 Answers0