[swift-users] Subclass doesn't inherit convenience initialiser
Krzysztof Siejkowski
krzysztof at siejkowski.net
Tue May 31 00:28:29 CDT 2016
Which swift version are you using? Your code works correctly for me on Swift 2.2 in the Playgrounds, apart from the wrong letter casing of the argument label (should be `URL`, not `url`).
On the separate note, your usecase seems like a great place for writing an extension of NSMutableURLRequest instead of inheriting from it.
Best,
Krzysztof
On 30 May 2016 at 21:00:12, Michal Kalinowski via swift-users (swift-users at swift.org) wrote:
Hello,
I'm subclassing NSMutableURLRequest to patch lack of httpBody property. My subclass doesn't implement any initialisers so it inherits all the designated initialisers. From what I understand, since all designated initialisers are implemented(inherited) then I should also inherit convenience initialisers.
My code:
class safe_NSMutableURLRequest: NSMutableURLRequest {
#if os(Linux)
var httpBody: NSData?
#endif
}
let someURL = NSURL(string: "https://google.com")!
let request =
safe_NSMutableURLRequest(url: someURL)
the last line produces an error:
error: incorrect argument label in call (have 'url:', expected 'coder:')
Could you please explain me why I'm not inheriting convenience initialiser?
Regards,
Michal Kalinowski
_______________________________________________
swift-users mailing list
swift-users at swift.org
https://lists.swift.org/mailman/listinfo/swift-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160531/5bb914e1/attachment.html>
More information about the swift-users
mailing list