I have an enum like
typedef NS_ENUM(NSInteger, MyEnum) {
MyEnumCase1,
MyEnumCase2,
...
};
and a function that maps those enum values to arbitrary strings
FOUNDATION_EXPORT NSString *myEnumString(MyEnum val);
Is it possible to expose this to Swift as a property?
I've tried
FOUNDATION_EXPORT NSString *myEnumString(MyEnum val) NS_SWIFT_NAME(MyEnum.stringVal);
but the compiler gives me the warning "'swift_name' attribute argument must be a string literal specifying a Swift function name" and Swift callers don't see stringVal
as a property on values of MyEnum
.
and I've tried
FOUNDATION_EXPORT NSString *myEnumString(MyEnum val) NS_REFINED_FOR_SWIFT;
but my Swift extension
extension MyEnum {
var stringVal {
return __myEnumString(self)
}
}
can't find __myEnumString()
.