I've implemented StringLiteralConvertible
, which extends ExtendedGraphemeClusterLiteralConvertible
. It looks like it wants me to implement that too. When I do, however, Xcode says it doesn't know what ExtendedGraphemeClusterLiteralType
is. I'm not sure what it wants from me...
extension NSURL : StringLiteralConvertible {
class func convertFromStringLiteral(value: StringLiteralType) -> Self {
return self(string: value)
}
class func convertFromExtendedGraphemeClusterLiteral(value: ExtendedGraphemeClusterLiteralType) -> Self {
// Use of undeclared type ExtendedGraphemeClusterLiteralType :( ?
}
}
let url : NSURL = "http://apple.com"
The problem is related to your extension not conforming to the protocol. If you CMD+Click on the StringLiteralConvertible protocol, to follow it to it's definition, you will find that the typealias StringLiteralType and typealias ExtendedGraphemeClusterLiteralType are set to String.
That being said, you should modify your extension to the following:
extension NSURL : StringLiteralConvertible {
class func convertFromStringLiteral(value: String) -> Self
{
//do what you were going to do
return self()
}
class func convertFromExtendedGraphemeClusterLiteral(value: String) -> Self{
//do what you were going to do
return self()
}
}
Information about typealias is described in "The Swift Programming Language" book from pages 606-609, under the section Associated Types.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With