Re: Trouble with imported enums in Swift
Re: Trouble with imported enums in Swift
- Subject: Re: Trouble with imported enums in Swift
- From: Rick Mann <email@hidden>
- Date: Mon, 20 Oct 2014 21:53:10 -0700
Sigh, I figured it out. Not only do you have to use NS_ENUM, the enumeration members MUST begin with the name of the enumeration.
> On Oct 20, 2014, at 19:43 , Roland King <email@hidden> wrote:
>
>
>> On 21 Oct 2014, at 10:23 am, Rick Mann <email@hidden> wrote:
>>
>>
>>> On Oct 20, 2014, at 19:17 , Roland King <email@hidden> wrote:
>>>
>>> well one is ‘==‘ and the other is ‘=‘ so not totally shocked there’s no error in the second one.
>>
>> Well, okay, but == sure is getting confused, but = sees the two types as compatible
>
> well it would, = takes an lvalue of a type and a type, which is what the error message says you have. You’d have thunk == would be smart enough to do the same but clearly it’s not or else they aren’t really the same type, but two different types with the same name or they aren’t enums which have == automagically defined on them (as long as they don’t have associated types).
>
>>
>>> Have you tried
>>>
>>> 1) a switch
>>
>> Type 'McpSweepState' does not conform to protocol 'IntervalType'
>>
>> (I've never been able to get switch to work)
>>
>>> 2) using .MCP_SWEEP_UNKNOWN or an even more totally qualified name McpSweepState.MCP_SWEEP_UNKNOWN
>>
>> Could not find member 'MCP_SWEEP_UNKNOWN'
>>
>>> 3) if !( mSweepState != MCP_SWEEP_UNKNOWN ) // I know you think I’m joking but I’m not
>>
>> Could not find an overload for '!' that accepts the supplied arguments
>>
>
> oh dear you do have some major borkage there. I have no idea what’s going on. Kind of looks like the enum didn’t bridge over as an enum but some other type which doesn’t conform to ‘==‘. Perhaps the typedef of the name 'enum XXX' to ‘XXX' upsets it.
>
> Only other thought I have is to change the original version to
>
> typedef NS_ENUM( NSInteger, McpSweepState )
> {
> // your enum values here
> }
>
> but I’m not entirely sure I hold out much hope for that either.
>
>> --
>> 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
--
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