Stefan Stefan - 10 months ago 48
Swift Question

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.



Answer Source

So for someone who has simillar issue:

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