-1

I have recently updated swift and I use a sidebar framework. Now when I load it, I get the following errors:

 override init() {
    super.init()

}

init(sourceView:UIView, menuItems:Array<String>){
    super.init()
    originView = sourceView

It highlights on the super.init() lines with this error:

property self.originView not initialized at super.init call

and highlights the originView = sourceView with

Immutable value self.originView may only be initialized once.

I'm not sure what's wrong because it's not my code and I need it to work. Any suggestions would be highly valued :)

2 Answers2

0

In the library code, originView is probably set as constant (let). Change it to var and see if it works.

rodrigoalvesvieira
  • 7,895
  • 15
  • 63
  • 84
0

In Swift you have to init your property self.originView like

class MySwiftclass: NSObject {
var originView = UIView(....)
}

or you can write

class MySwiftclass: NSObject {
var originView: UIView!
}

or you can write

class MySwiftclass: NSObject {
var originView: UIView?
}
Miralem Cebic
  • 1,276
  • 1
  • 15
  • 28