• 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: Raw Swift
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Raw Swift


  • Subject: Re: Raw Swift
  • From: Greg Parker <email@hidden>
  • Date: Thu, 18 Sep 2014 18:45:27 -0700

> On Sep 18, 2014, at 5:45 PM, Gerriet M. Denkmann <email@hidden> wrote:
>
> This works fine in Xcode 6.0.1:
>
> import Cocoa
>
> enum ButtonTitle : String
> {
> 	case TitelStop	= "Stop"
> 	case TitelDone	= "Done"
> }
>
> let buttonMode = ButtonTitle.TitelDone
>
> let mode = ButtonTitle.toRaw( buttonMode )()
>
>
> But Xcode 6.1 beta 2 says: "error: 'ButtonTitle.Type' does not have a member named 'toRaw'"
>
> Syntax change in Swift? Bug in Xcode? Bug in my code?

Syntax change. From the beta 2 release notes:

"
The RawRepresentable protocol that enums with raw types implicitly conform to has been redefined to take advantage of failable initializers. The fromRaw(RawValue) static method has been replaced with an initializer init?(rawValue: RawValue), and the toRaw() method has been replaced with a rawValue property. Enums with raw types can now be used like this:
    enum Foo: Int { case A = 0, B = 1, C = 2 }
    let foo = Foo(rawValue: 2)! // formerly 'Foo.fromRaw(2)!’
    println(foo.rawValue) // formerly 'foo.toRaw()'
"


--
Greg Parker     email@hidden     Runtime Wrangler



_______________________________________________

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: 
 >Raw Swift (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: Re: Raw Swift
  • Next by Date: Re: Still need help with Services. Is there sample code?
  • Previous by thread: Re: Raw Swift
  • Next by thread: About the Bundle creator OS Type code
  • Index(es):
    • Date
    • Thread