Trouble with imported enums in Swift
Trouble with imported enums in Swift
- Subject: Trouble with imported enums in Swift
- From: Rick Mann <email@hidden>
- Date: Mon, 20 Oct 2014 19:03:04 -0700
I'm having weird trouble using a C enumeration imported via bridging header from swift. I can define an instance variable and initialize it using the enum, but I can't compare the enum:
Camera.swift:60:18: Cannot invoke '==' with an argument list of type '(@lvalue McpSweepState, McpSweepState)'
The code is here:
class
MyClass
{
func
getCameraState()
-> McpCameraState
{
if mSweepState == MCP_SWEEP_UNKNOWN // <---- error here
{
return MCP_STATE_SWEEP_IN_PROGRESS;
}
else
{
return MCP_STATE_READY;
}
}
var mSweepState: McpSweepState = MCP_SWEEP_UNKNOWN; // <--- no error
}
------------------------------------------------------------
Imported via bridging header:
enum McpSweepState
{
MCP_SWEEP_UNKNOWN = 0,
MCP_SWEEP_EMPTY = 1,
MCP_SWEEP_ROTATING = 2,
MCP_SWEEP_PROCESSING = 3,
MCP_SWEEP_COMPLETE = 4,
MCP_SWEEP_CANCELED = 5,
MCP_SWEEP_ABORTED_PHYSICAL = 6,
MCP_SWEEP_ABORTED_DATA = 7,
MCP_SWEEP_ERROR = 8,
};
typedef enum McpSweepState McpSweepState;
enum McpCameraState
{
MCP_STATE_UNKNOWN = 0,
MCP_STATE_READY = 1,
MCP_STATE_SWEEP_IN_PROGRESS = 2,
MCP_STATE_BLOCKED = 3,
};
typedef enum McpCameraState McpCameraState;
--
Rick Mann
email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden