Re: Trouble with imported enums in Swift
Re: Trouble with imported enums in Swift
- Subject: Re: Trouble with imported enums in Swift
- From: Roland King <email@hidden>
- Date: Tue, 21 Oct 2014 10:17:02 +0800
> On 21 Oct 2014, at 10:03 am, Rick Mann <email@hidden> wrote:
>
> 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
> }
>
> —
well one is ‘==‘ and the other is ‘=‘ so not totally shocked there’s no error in the second one.
Have you tried
1) a switch
2) using .MCP_SWEEP_UNKNOWN or an even more totally qualified name McpSweepState.MCP_SWEEP_UNKNOWN
3) if !( mSweepState != MCP_SWEEP_UNKNOWN ) // I know you think I’m joking but I’m not
_______________________________________________
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