[swift-users] Subclass doesn't inherit convenience initialiser

Michal Kalinowski michal.kalinowski at icloud.com
Mon May 30 13:59:50 CDT 2016


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160530/6ebb55b5/attachment.html>


More information about the swift-users mailing list