From 8fc70ff8bd46c3ae208f10edffba5286ce5c408f Mon Sep 17 00:00:00 2001 From: Guangming Mao Date: Sat, 18 Oct 2014 23:51:24 +0800 Subject: [PATCH] enumerations has no rawValue member now --- 8. Enumerations.playground/contents.xcplayground | 2 +- 8. Enumerations.playground/section-1.swift | 10 +++++----- 8. Enumerations.playground/timeline.xctimeline | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/8. Enumerations.playground/contents.xcplayground b/8. Enumerations.playground/contents.xcplayground index 18a12f6..8e39341 100644 --- a/8. Enumerations.playground/contents.xcplayground +++ b/8. Enumerations.playground/contents.xcplayground @@ -4,4 +4,4 @@ - + \ No newline at end of file diff --git a/8. Enumerations.playground/section-1.swift b/8. Enumerations.playground/section-1.swift index acf994d..d908dea 100644 --- a/8. Enumerations.playground/section-1.swift +++ b/8. Enumerations.playground/section-1.swift @@ -118,8 +118,8 @@ enum StatusCode: Int case YetAnotherResult // Unspecified values are auto-incremented from the previous value } -// We can get the raw value of an enumeration value with the rawValue member: -StatusCode.OtherResult.rawValue +// We can get the raw value of an enumeration value with the toRaw() method: +StatusCode.OtherResult.toRaw() // We can give enumerations many types. Here's one of type Character: enum ASCIIControlCharacter: Character @@ -143,18 +143,18 @@ enum FamilyPet: String } // And we can get their raw value as well: -FamilyPet.Ferret.rawValue +FamilyPet.Ferret.toRaw() // We can also generate the enumeration value from the raw value. Note that this is an optional // because not all raw values will have a matching enumeration: -var pet = FamilyPet(rawValue: "Ferret") +var pet = FamilyPet.fromRaw("Ferret") // Let's verify this: if pet != .None { "We have a pet!" } else { "No pet :(" } // An example of when a raw doesn't translate to an enum, leaving us with a nil optional: -pet = FamilyPet(rawValue: "Snake") +pet = FamilyPet.fromRaw("Snake") if pet != .None { "We have a pet" } else { "No pet :(" } diff --git a/8. Enumerations.playground/timeline.xctimeline b/8. Enumerations.playground/timeline.xctimeline index 2e9ebb7..d666e7f 100644 --- a/8. Enumerations.playground/timeline.xctimeline +++ b/8. Enumerations.playground/timeline.xctimeline @@ -3,7 +3,7 @@ version = "3.0"> + documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=5523&EndingColumnNumber=5&EndingLineNumber=20&StartingColumnNumber=4&StartingLineNumber=20&Timestamp=435340083.485168">