Using non NS_ENUM objective-C enum in swift -


I am using Wahoo Fitness API and it defines the objective-C enum:

  Typingfem Enum {/ ** is not an active connection * / WF_SENSOR_CONNECTION_STATUS_IDLE, / ** The connection is in the process of being established. * / WF_SENSOR_CONNECTION_STATUS_CONNECTING, / ** Sensor connection is established and active. * / WF_SENSOR_CONNECTION_STATUS_CONNECTED, / ** The connection was interrupted (usually when the fish is disconnected). * / WF_SENSOR_CONNECTION_STATUS_INTERRUPTED, / ** The connection is in the process of disconnecting. * / WF_SENSOR_CONNECTION_STATUS_DISCONNECTING, WFSensorConnectionStatus_t;   

I can not find a way to use it faster I successfully tried to make a switch / case without it. I am doing a point to take on the bus. want to try the following:

  var connState: WFSensorConnectionStatus_t = WF_SENSOR_CONNECTION_STATUS_IDLE ... if (connState == WF_SENSOR_CONNECTION_STATUS_IDLE) {  

but this compilation does not:

    

Priwart any workaround National is? WFSensorConnectionStatus_t.WF_SENSOR_CONNECTION_STATUS_IDLE or WF_SENSOR_CONNECTION_STATUS_IDLE.value but it does not work in xcode Beta 4 I read to use.

After "text" itemprop = "text">

to use the solution .Value to obtain> the underlying integer now in beta 4 Does not work, as you said.

Unfortunately a Enum Swift is not Tronsfrakshnl of Objective-C, it should be a NS_ENUM .

I have a project where I need the enum from an Objective-C framework and use it in Swift

The solution I did was one objective-C was to create a range that an NS_ENUM and I transfer framework values ​​of enum to its own NS_ENUM .

Import the category into your bridging header and you should generally be able to use enum while doing this

typedef NS_ENUM (NSUInteger, ConnectionStatus ConnectionStatusIdle - ConnectionStatus connectionStatus {If [Self-Connection Connection] == WF_SENSOR_CONNECTION_STATUS_IDLE {Return ConnectionStatusIdle}}

Then you should be able to use it like this:

  switch myObject.connectionStatus () {case .Idle: // break something}    

Comments

Popular posts from this blog

c# - Textbox not clickable but editable -

Matlab transpose a table vector -

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -