Implementing StringLiteralConvertible on NSURL in Swift 1.1

后端 未结 1 456
长情又很酷
长情又很酷 2020-12-19 18:47

Here is an older question on the same topic, but it is for Swfit 1.0. In Swift 1.1, the StringLiteralConvertible protocol has changed to use initializers instea

相关标签:
1条回答
  • 2020-12-19 19:14

    The initializers required by the protocol "StringLiteralConvertible" do not return optionals, so putting a ? after init won't help (even though XCode itself suggests it). But all initializers for NSURL do return optionals, because the parameters may not result in a valid URL. And you have to call one of the super.init initializers in all custom NSURL initializers. So it is no longer possible to have NSURL implement "StringLiteralConvertible".

    0 讨论(0)
提交回复
热议问题