Stefan
Stefan

Reputation: 5461

Swift method with a swift enum as parameter is not visible in Objective C

I have a swift Class with an enum and a method which expects a parameter of with type of the enum:

import SpriteKit

enum Direction: Int {
    case up = 1;
    case down = -1;
}

class ParallaxScrollingNode: SKNode {

    func addStaticBackground(name: String) {
        ...
    }

    func addParallaxBackground(imageNames: [String], yScaleFactor: CGFloat, yDirection: Direction) {
        ...
    }

In my Objective C class it is possible to call the first, but not the second method:

enter image description here

Looks like the enum is causing the issue. The method is missile, if I change the type to Int. Of course I can do this with my code, but I want to understand if this is not working in general or if I have missed something.

Thanks
Stefan

Upvotes: 1

Views: 1090

Answers (1)

rkyr
rkyr

Reputation: 3251

So for someone who has simillar issue:

adding @objc specification before declaration makes this struct available in Objective-C world.

Docs.

Upvotes: 3

Related Questions