1

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

2
  • 2
    try add @objc before enum declaration Commented Nov 26, 2015 at 22:53
  • @rkyr that worked. Many thanks. Commented Nov 27, 2015 at 7:15

1 Answer 1

3

So for someone who has simillar issue:

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

Docs.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.