Convert to UInt32 in Swift from NS_ENUM uint32_t in Objective-C

43 views Asked by At

I have this code...

Objective-c:

typedef NS_ENUM(uint32_t, EXType) {
  EXTypeBad = 0,
  EXTypeOK,
  EXTypeGood
};

EXType type = EXTypeOK;

Swift

 UInt32(type)

But I get:

initializer 'init(_:radix:)' requires that 'EXType' conform to 'StringProtocol' type: UInt32(type)

What am I doing wrong? Thanks.

1

There are 1 answers

1
Rik On BEST ANSWER

I was able to use the rawValue property on the NSEnum. My Autocomplete didn't suggest this to me.

UInt32(type.rawValue)