error within custom initialiser in extension of class

Viewed 384

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 ?

0 Answers
Related