0

I have class Parent like this:

class Parent {
    init? (data: AnyObject) { }
}

I have class Child like this:

class Child : Parent {
    init? (info: AnyObject) { }
}

When I write code like this:

let obj = Child (data: someData);

I get error:

Incorrect argument label in call (have 'data:', expected 'info:')

But if I remove the constructor at child, the error disappears.

How can I have both of the constructors at child? Thanks.

Chen Li Yong
  • 5,459
  • 8
  • 58
  • 124
  • 1
    Read the [Initializer Inheritance and Overriding](https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Initialization.html#//apple_ref/doc/uid/TP40014097-CH18-ID221) section of the Swift book. – rmaddy Sep 04 '17 at 03:06
  • 1
    See https://stackoverflow.com/a/31459131/1226963 for your answer. – rmaddy Sep 04 '17 at 03:09
  • Oh ok I get it now. Thanks! – Chen Li Yong Sep 04 '17 at 03:34

0 Answers0