1

A newbie to swift

I'm doing a mixed-language (Swift & Objective-C) program, and encounter an error when trying to import Swift into Objective-C

here is my code

@objc public enum ItemType: Int {
  case left, right
}
public class MyClass {
  @objc var items: [ItemType] = []
}

Here is the error enter image description here

It seems that there's something wrong about the ItemType but I do see the definition of ItemType in my -swift.h file

Could any one give me a hint?

Jimmy
  • 55
  • 5

1 Answers1

0

Swift and Objective-c enums is very different in their nature. Old Objective-c enum is very little subset of modern Swift enum. Currently compiler doesn't know how to use Swift's enum from Objective-c code so they can't be @objc type. MyClass also can't be @objc type while it contain swift's enum.