• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Trouble with imported enums in Swift
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trouble with imported enums in Swift


  • Subject: Re: Trouble with imported enums in Swift
  • From: Rick Mann <email@hidden>
  • Date: Tue, 21 Oct 2014 14:35:42 -0700

> On Oct 21, 2014, at 14:26 , Quincey Morris <email@hidden> wrote:
>
> On Oct 21, 2014, at 13:33 , Rick Mann <email@hidden> wrote:
>>
>> Honestly, though, I don't see why Swift can't just deal with "plain" enums.
>
> Because it’s not an Obj-C compiler?
>
> I suspect that the reason you saw the “incomplete” behavior is that you declared the enum in two parts:
>
>> 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;
>
> Under this theory, Swift is able to parse the typedef, so it knows that ‘McpSweepState’ is a type, and  maybeeven an enum, but it doesn’t know what the values are. That might be enough to let it assign, but not to compare (since == is not a built-in operator).
>
> Or, it might be that it can parse the enum, but it doesn’t know its underlying type, since you didn’t say ‘enum McpSweepState : NSUInteger’ or some such.
>
> Honestly, though, I don’t see why you can’t just deal with writing enums the “compatible” way.

Because the file whence it comes is part of a library of C++ code that also has to run on Linux.


--
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


  • Follow-Ups:
    • Re: Trouble with imported enums in Swift
      • From: Quincey Morris <email@hidden>
References: 
 >Trouble with imported enums in Swift (From: Rick Mann <email@hidden>)
 >Re: Trouble with imported enums in Swift (From: Roland King <email@hidden>)
 >Re: Trouble with imported enums in Swift (From: Rick Mann <email@hidden>)
 >Re: Trouble with imported enums in Swift (From: Roland King <email@hidden>)
 >Re: Trouble with imported enums in Swift (From: Rick Mann <email@hidden>)
 >Re: Trouble with imported enums in Swift (From: "Raglan T. Tiger" <email@hidden>)
 >Re: Trouble with imported enums in Swift (From: Rick Mann <email@hidden>)
 >Re: Trouble with imported enums in Swift (From: Greg Parker <email@hidden>)
 >Re: Trouble with imported enums in Swift (From: Rick Mann <email@hidden>)
 >Re: Trouble with imported enums in Swift (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: Trouble with imported enums in Swift
  • Next by Date: Re: Trouble with imported enums in Swift
  • Previous by thread: Re: Trouble with imported enums in Swift
  • Next by thread: Re: Trouble with imported enums in Swift
  • Index(es):
    • Date
    • Thread