2

My Swift-Class defines an initWith.. method by the following code

convenience init(controlType: ApplePencilControlType) {

    self.init(frame: CGRect())

    type = controlType

    self.frame = self.controlFrame

    if type == .zoom {

        zoomSlider = UISlider(frame: CGRect(x: 10, y: 10, width: 100, height: 20))

        if let slider = zoomSlider {

            self.addSubview(slider)
        }
    }
    else if type == .toLeft || type == .toRight {

        imageView = UIImageView(frame: CGRect(x: 5, y: 5, width: 20, height: 20))

        if let imgView = imageView {

            if let img = type.image {

                imgView.image = img
            }

            self.addSubview(imgView)
        }
    }
}

Trying to call this method by the following Objective-C Code makes Xcode show up an error.

- (void)presentOrHidePencilControls {

    self.apToLeft = [[ApplePencilControl alloc] initWithControlType:ApplePencilControlTypeToLeft];
}

The error is No visible @interface for 'ApplePencilControl' declares the selector 'initWithControlType:'

What have I to do, so i can call this initializer from Objective-C? The "Project/Modul-Swift.h" is already imported.

regetskcob
  • 1,172
  • 1
  • 13
  • 35

1 Answers1

0

I had to insert @objc and : Int to my enum definition in the same class.

regetskcob
  • 1,172
  • 1
  • 13
  • 35