Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot invoke initializer for type 'CustomDetailView' with no arguments

Tags:

ios

swift3

Getting error while I'm trying to do is simply create an instance of my custom class

class CustomDetailView: UIImageView {
  let packThumbImage = UIImageView()
  let packFrameImage = UIImageView()
  let packNameLabel = UILabel()

 required init?(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)
 }

 override init(frame: CGRect) {
    super.init(frame: frame)   
  }
}

var customPackView = CustomDetailView() // error here

like image 415
Karthikeyan Bose Avatar asked Nov 03 '16 10:11

Karthikeyan Bose


1 Answers

var customPackView = CustomDetailView(frame: CGRect.zero) 

Edit: You have no empty initializer. Thus, you must use an initializer with a parameter.

like image 128
clemens Avatar answered Sep 19 '22 16:09

clemens