I am new with Swift. I inherited a project. I saw it running on a device. However, when I checkout the code and it had many errors. I was able to clear out the errors. However, I run into this one that is baffling me. The project uses xib files as well. Here is the code.
required init(coder aDecoder: NSCoder) { super.init(coder: aDecoder) } override init(frame: CGRect) { super.init(frame: frame) } init(items:NSArray, viewController:AnyObject){ super.init() //itemsArray = items itemsArray = items as [AnyObject] //commonInit(viewController as UIViewController) commonInit(viewController as! UIViewController) }
I get the error under the init(items:NSArray, viewController:AnyObject) method/function. The error is pointed at the "super.init()". It states "Must call a designated initializer of the superclass 'UIView' error"
I been searching, googling, asking others and nothing has turned up. Can I get help on fixing this error, or at least why this error happens? I would like understand so I can become a better software developer.
Edit: I would like to thank everyone for their insight and help. I found out the problem is bigger. I did the changes suggested in the super.init(frame: CGRect). I had to change an array property as well which was affecting the init function.
As the error message suggests you can only call the designated initializer of the superclass.
To solve this you need to call : super.init(frame: frame)
instead of super.init()
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