Question or problem in the Swift programming language:
The code was working well before the upgrade to Xcode 7.3 from 7.1 and swift 2.2. I have also seen answers using the typedef NS_ENUM(NSUInteger, MyStatus)… but if possible, I prefer not to change the existing obj-c code.
Defined in obj-c header file:
typedef enum { StatusPending, StatusTimeout, StatusSuccess, StatusFail } MyStatus;
Statement in Swift file:
/* some code to retrieve the status */ switch (status) { case .StatusSuccess: /* do something */ /* other test cases omitted here */ default: }
I’ve tried using .rawValue, .value, etc, but I still get an error:
Enum case ‘StatusSuccess’ not found in type ‘MyStatus’
All was working fine before the upgrade and have tried uninstalling/reinstalling Xcode 7.3, Product->Clean, Product->Clean Build Folder.. but without success 🙁
How to solve the problem:
You can’t declare “typedef NS_ENUM (NSUInteger, EnumName){}” within @interface and @end, the parsing of xcode 7.2 is different from xcode 7.3. So, just move your enum declarations outside @interface @end block and it should work fine, otherwise its considered a private declaration