• 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: Question about enums
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about enums


  • Subject: Re: Question about enums
  • From: Michael de Haan  <email@hidden>
  • Date: Fri, 17 Jul 2015 13:42:24 -0700

I did look at that, but , certainly in Playground, it produces this error.

enum with raw type cannot have cases with arguments case Custom(String)

On Jul 17, 2015, at 1:33 PM, Stephen J. Butler <email@hidden> wrote:
>
> How about using a Custom option with an associated String value?
>
> enum Foo:String {
>
>     case Bar = “Bar"
>     case Etc = “Etc"
>     case Etc_Etc = “Etc Etc"
>     case Custom(String)
>  }
>
>
> On Fri, Jul 17, 2015 at 2:53 PM, Michael de Haan  <email@hidden <mailto:email@hidden>> wrote:
> I wonder if I can get some input as I seemed to have hit a wall in Swift, 2.0
>
> My App uses structs and enums to hold the bulk of the data needed for it’s  default values (probably over 95%). So, for example,
>
> enum Foo:String {
>
>     case Bar = “Bar"
>     case Etc = “Etc"
>     case Etc_Etc = “Etc Etc"
>  }
>
>
> As a very small percentage of the app, I want to allow the user to add a custom “raw-Value" of Type Foo. In essence, it would be as if the user had added another case to the enum.
>
>
>
>  let x = Foo(rawValue: “newRawValue”) not unsurprisingly,  returns “nil".
>
> I know that I could use Core Data to store the data, but it seems that for so trivial amount of user data,I should be able to do it without resorting to Core Data.
>
> Or, I may be approaching it the wrong way entirely.
>
> Your thoughts would be greatly appreciated.
>
>
>
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden <mailto: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 <http://lists.apple.com/>
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden <mailto: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


References: 
 >Question about enums (From: Michael de Haan  <email@hidden>)
 >Re: Question about enums (From: "Stephen J. Butler" <email@hidden>)

  • Prev by Date: Re: Question about enums
  • Next by Date: Re: Question about enums
  • Previous by thread: Re: Question about enums
  • Next by thread: Strange behavior of view based NSTableView with NSTextView
  • Index(es):
    • Date
    • Thread