From a34e157d68994d2f55250ab5f71fcef632e91382 Mon Sep 17 00:00:00 2001 From: Paul Nettle Date: Tue, 16 Sep 2014 18:27:07 -0500 Subject: [PATCH] Updated to support XCode 6.0 GM. This includes the latest updates to the language specification but also alters the project settings for the playgrounds to target 'iossimulator' rather than 'macosx'. This was necessary as the release of XCode 6.0 GM broke playgrounds that targeted OSX. This new configuration does work on both of the current versions of XCode (6.0 GM and 6.1 Beta 2) --- .../contents.xcplayground | 4 +-- 11. Methods.playground/contents.xcplayground | 4 +-- .../contents.xcplayground | 4 +-- .../contents.xcplayground | 4 +-- .../contents.xcplayground | 4 +-- .../contents.xcplayground | 4 +-- .../contents.xcplayground | 4 +-- 16. ARC.playground/contents.xcplayground | 4 +-- .../contents.xcplayground | 4 +-- .../contents.xcplayground | 4 +-- .../contents.xcplayground | 4 +-- 19. Nested Types.playground/section-1.swift | 6 ++--- .../timeline.xctimeline | 2 +- .../contents.xcplayground | 4 +-- .../contents.xcplayground | 4 +-- 1c. Tuples.playground/contents.xcplayground | 4 +-- .../contents.xcplayground | 4 +-- 1d. Optionals.playground/section-1.swift | 2 +- 1d. Optionals.playground/timeline.xctimeline | 2 +- .../contents.xcplayground | 4 +-- .../contents.xcplayground | 4 +-- .../section-1.swift | 11 +++----- .../timeline.xctimeline | 2 +- .../contents.xcplayground | 4 +-- 20. Extensions.playground/section-1.swift | 12 --------- 20. Extensions.playground/timeline.xctimeline | 2 +- .../contents.xcplayground | 4 +-- 22. Generics.playground/contents.xcplayground | 4 +-- .../contents.xcplayground | 4 +-- .../contents.xcplayground | 4 +-- .../section-1.swift | 8 ------ .../timeline.xctimeline | 2 +- 4a. Arrays.playground/contents.xcplayground | 4 +-- .../contents.xcplayground | 4 +-- .../contents.xcplayground | 4 +-- 5. Control Flow.playground/section-1.swift | 6 ++--- .../timeline.xctimeline | 2 +- 6. Functions.playground/contents.xcplayground | 4 +-- 7. Closures.playground/contents.xcplayground | 4 +-- .../contents.xcplayground | 4 +-- 8. Enumerations.playground/section-1.swift | 10 +++---- .../timeline.xctimeline | 2 +- .../contents.xcplayground | 4 +-- .../contents.xcplayground | 4 +-- 99. Not The End.playground/section-1.swift | 26 ------------------- .../timeline.xctimeline | 2 +- README.md | 3 ++- 47 files changed, 85 insertions(+), 135 deletions(-) diff --git a/10. Properties.playground/contents.xcplayground b/10. Properties.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/10. Properties.playground/contents.xcplayground +++ b/10. Properties.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/11. Methods.playground/contents.xcplayground b/11. Methods.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/11. Methods.playground/contents.xcplayground +++ b/11. Methods.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/12. Subscripts.playground/contents.xcplayground b/12. Subscripts.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/12. Subscripts.playground/contents.xcplayground +++ b/12. Subscripts.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/13. Inheritance.playground/contents.xcplayground b/13. Inheritance.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/13. Inheritance.playground/contents.xcplayground +++ b/13. Inheritance.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/14a. Initialization.playground/contents.xcplayground b/14a. Initialization.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/14a. Initialization.playground/contents.xcplayground +++ b/14a. Initialization.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/14b. Initializer Chaining.playground/contents.xcplayground b/14b. Initializer Chaining.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/14b. Initializer Chaining.playground/contents.xcplayground +++ b/14b. Initializer Chaining.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/15. Deinitialization.playground/contents.xcplayground b/15. Deinitialization.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/15. Deinitialization.playground/contents.xcplayground +++ b/15. Deinitialization.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/16. ARC.playground/contents.xcplayground b/16. ARC.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/16. ARC.playground/contents.xcplayground +++ b/16. ARC.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/17. Optional Chaining.playground/contents.xcplayground b/17. Optional Chaining.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/17. Optional Chaining.playground/contents.xcplayground +++ b/17. Optional Chaining.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/18. Type Casting.playground/contents.xcplayground b/18. Type Casting.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/18. Type Casting.playground/contents.xcplayground +++ b/18. Type Casting.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/19. Nested Types.playground/contents.xcplayground b/19. Nested Types.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/19. Nested Types.playground/contents.xcplayground +++ b/19. Nested Types.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/19. Nested Types.playground/section-1.swift b/19. Nested Types.playground/section-1.swift index 02b8065..e34d5b4 100644 --- a/19. Nested Types.playground/section-1.swift +++ b/19. Nested Types.playground/section-1.swift @@ -54,7 +54,7 @@ struct BlackjackCard case .Jack, .Queen, .King: return Values(first: 10, second: nil) default: - return Values(first: self.toRaw(), second: nil) + return Values(first: self.rawValue, second: nil) } } } @@ -65,7 +65,7 @@ struct BlackjackCard var description: String { - var output = "A \(suit.toRaw()) with a value of \(rank.values.first)" + var output = "A \(suit.rawValue) with a value of \(rank.values.first)" if let second = rank.values.second { output += " or \(second)" @@ -84,4 +84,4 @@ let theAceOfSpades = BlackjackCard(rank: .Ace, suit: .Spades) theAceOfSpades.description // To access the nested type, we can drill down into the type using type names: -let heartsSymbol = String( BlackjackCard.Suit.Hearts.toRaw() ) +let heartsSymbol = String( BlackjackCard.Suit.Hearts.rawValue ) diff --git a/19. Nested Types.playground/timeline.xctimeline b/19. Nested Types.playground/timeline.xctimeline index 5d9e6d1..4d92167 100644 --- a/19. Nested Types.playground/timeline.xctimeline +++ b/19. Nested Types.playground/timeline.xctimeline @@ -3,7 +3,7 @@ version = "3.0"> + documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=3047&EndingColumnNumber=5&EndingLineNumber=2&StartingColumnNumber=4&StartingLineNumber=2&Timestamp=432601065.869592"> diff --git a/1a. The Basics.playground/contents.xcplayground b/1a. The Basics.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/1a. The Basics.playground/contents.xcplayground +++ b/1a. The Basics.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/1b. Type alliases.playground/contents.xcplayground b/1b. Type alliases.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/1b. Type alliases.playground/contents.xcplayground +++ b/1b. Type alliases.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/1c. Tuples.playground/contents.xcplayground b/1c. Tuples.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/1c. Tuples.playground/contents.xcplayground +++ b/1c. Tuples.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/1d. Optionals.playground/contents.xcplayground b/1d. Optionals.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/1d. Optionals.playground/contents.xcplayground +++ b/1d. Optionals.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/1d. Optionals.playground/section-1.swift b/1d. Optionals.playground/section-1.swift index 157c904..5383b35 100644 --- a/1d. Optionals.playground/section-1.swift +++ b/1d. Optionals.playground/section-1.swift @@ -176,7 +176,7 @@ assumedString = nil // let errorString: String = assumedString // Like any other optional, we can still check if it holds a value: -if assumedString +if assumedString != nil { "We have a value" } diff --git a/1d. Optionals.playground/timeline.xctimeline b/1d. Optionals.playground/timeline.xctimeline index f49c185..ba175f8 100644 --- a/1d. Optionals.playground/timeline.xctimeline +++ b/1d. Optionals.playground/timeline.xctimeline @@ -3,7 +3,7 @@ version = "3.0"> + documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=6950&EndingColumnNumber=5&EndingLineNumber=2&StartingColumnNumber=4&StartingLineNumber=2&Timestamp=432600545.276631"> diff --git a/1e. Assertions.playground/contents.xcplayground b/1e. Assertions.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/1e. Assertions.playground/contents.xcplayground +++ b/1e. Assertions.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/2. Basic operations.playground/contents.xcplayground b/2. Basic operations.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/2. Basic operations.playground/contents.xcplayground +++ b/2. Basic operations.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/2. Basic operations.playground/section-1.swift b/2. Basic operations.playground/section-1.swift index 5dab6f2..6bbaeda 100644 --- a/2. Basic operations.playground/section-1.swift +++ b/2. Basic operations.playground/section-1.swift @@ -76,15 +76,10 @@ a + b // String concatenation uses the + operator: "hello, " + "world" -// You can add characters, too, which form a string +// To add characters, convert them to a string let dog: Character = "🐶" -let cow: Character = "🐮" // Why is this an "Enum Value" ? -let dogCow = dog + cow - -// You can also add characters to a string -let str = "abc" -let chr: Character = "d" -chr + str + chr +let cow: Character = "🐮" +let dogCow = String(dog) + String(cow) // Ternary operators work on three targets: truefalse ? a : b diff --git a/2. Basic operations.playground/timeline.xctimeline b/2. Basic operations.playground/timeline.xctimeline index f2cfc23..9a87e18 100644 --- a/2. Basic operations.playground/timeline.xctimeline +++ b/2. Basic operations.playground/timeline.xctimeline @@ -3,7 +3,7 @@ version = "3.0"> + documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=3422&EndingColumnNumber=5&EndingLineNumber=2&StartingColumnNumber=4&StartingLineNumber=2&Timestamp=432600756.313844"> diff --git a/20. Extensions.playground/contents.xcplayground b/20. Extensions.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/20. Extensions.playground/contents.xcplayground +++ b/20. Extensions.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/20. Extensions.playground/section-1.swift b/20. Extensions.playground/section-1.swift index 32a6b0a..19b54e1 100644 --- a/20. Extensions.playground/section-1.swift +++ b/20. Extensions.playground/section-1.swift @@ -187,15 +187,3 @@ extension Character Character("a").kind == .Vowel Character("h").kind == .Consonant Character("+").kind == .Other - - - - - - - - - - - - diff --git a/20. Extensions.playground/timeline.xctimeline b/20. Extensions.playground/timeline.xctimeline index 26d85f0..94658f5 100644 --- a/20. Extensions.playground/timeline.xctimeline +++ b/20. Extensions.playground/timeline.xctimeline @@ -3,7 +3,7 @@ version = "3.0"> + documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=5366&EndingColumnNumber=5&EndingLineNumber=2&StartingColumnNumber=4&StartingLineNumber=2&Timestamp=432601082.881947"> diff --git a/21. Protocols.playground/contents.xcplayground b/21. Protocols.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/21. Protocols.playground/contents.xcplayground +++ b/21. Protocols.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/22. Generics.playground/contents.xcplayground b/22. Generics.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/22. Generics.playground/contents.xcplayground +++ b/22. Generics.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/23. Advanced Operators.playground/contents.xcplayground b/23. Advanced Operators.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/23. Advanced Operators.playground/contents.xcplayground +++ b/23. Advanced Operators.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/3. Strings and Characters.playground/contents.xcplayground b/3. Strings and Characters.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/3. Strings and Characters.playground/contents.xcplayground +++ b/3. Strings and Characters.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/3. Strings and Characters.playground/section-1.swift b/3. Strings and Characters.playground/section-1.swift index 54dade8..e78b818 100644 --- a/3. Strings and Characters.playground/section-1.swift +++ b/3. Strings and Characters.playground/section-1.swift @@ -69,14 +69,6 @@ countElements(originalString) // Strings can be concatenated with strings and characters var helloworld = "hello, " + "world" -// Add a character -var bang: Character = "!" -helloworld + bang - -// Concatenate a character onto the end of the string -helloworld += bang -helloworld - // ------------------------------------------------------------------------------------------------ // String interpolation // diff --git a/3. Strings and Characters.playground/timeline.xctimeline b/3. Strings and Characters.playground/timeline.xctimeline index 4185d5a..ceeb430 100644 --- a/3. Strings and Characters.playground/timeline.xctimeline +++ b/3. Strings and Characters.playground/timeline.xctimeline @@ -3,7 +3,7 @@ version = "3.0"> + documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=3293&EndingColumnNumber=5&EndingLineNumber=9&StartingColumnNumber=4&StartingLineNumber=9&Timestamp=432600783.307522"> diff --git a/4a. Arrays.playground/contents.xcplayground b/4a. Arrays.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/4a. Arrays.playground/contents.xcplayground +++ b/4a. Arrays.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/4b. Dictionaries.playground/contents.xcplayground b/4b. Dictionaries.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/4b. Dictionaries.playground/contents.xcplayground +++ b/4b. Dictionaries.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/5. Control Flow.playground/contents.xcplayground b/5. Control Flow.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/5. Control Flow.playground/contents.xcplayground +++ b/5. Control Flow.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/5. Control Flow.playground/section-1.swift b/5. Control Flow.playground/section-1.swift index 8780f44..75753f2 100644 --- a/5. Control Flow.playground/section-1.swift +++ b/5. Control Flow.playground/section-1.swift @@ -367,7 +367,7 @@ nameLoop: for name in names break characterLoop default: - result += character + result += String(character) } } } @@ -386,7 +386,7 @@ nameLoop: for name in names continue characterLoop default: - result += character + result += String(character) } } } @@ -406,7 +406,7 @@ nameLoop: for name in names break nameLoop default: - result += character + result += String(character) } } } diff --git a/5. Control Flow.playground/timeline.xctimeline b/5. Control Flow.playground/timeline.xctimeline index c3a3538..c1278f9 100644 --- a/5. Control Flow.playground/timeline.xctimeline +++ b/5. Control Flow.playground/timeline.xctimeline @@ -3,7 +3,7 @@ version = "3.0"> + documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=11017&EndingColumnNumber=5&EndingLineNumber=2&StartingColumnNumber=4&StartingLineNumber=2&Timestamp=432600844.500701"> diff --git a/6. Functions.playground/contents.xcplayground b/6. Functions.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/6. Functions.playground/contents.xcplayground +++ b/6. Functions.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/7. Closures.playground/contents.xcplayground b/7. Closures.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/7. Closures.playground/contents.xcplayground +++ b/7. Closures.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/8. Enumerations.playground/contents.xcplayground b/8. Enumerations.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/8. Enumerations.playground/contents.xcplayground +++ b/8. Enumerations.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/8. Enumerations.playground/section-1.swift b/8. Enumerations.playground/section-1.swift index d908dea..acf994d 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 toRaw() method: -StatusCode.OtherResult.toRaw() +// We can get the raw value of an enumeration value with the rawValue member: +StatusCode.OtherResult.rawValue // 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.toRaw() +FamilyPet.Ferret.rawValue // 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.fromRaw("Ferret") +var pet = FamilyPet(rawValue: "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.fromRaw("Snake") +pet = FamilyPet(rawValue: "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 688b2c2..2e9ebb7 100644 --- a/8. Enumerations.playground/timeline.xctimeline +++ b/8. Enumerations.playground/timeline.xctimeline @@ -3,7 +3,7 @@ version = "3.0"> + documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=5526&EndingColumnNumber=5&EndingLineNumber=20&StartingColumnNumber=4&StartingLineNumber=20&Timestamp=432600934.12383"> diff --git a/9. Classes and Structures.playground/contents.xcplayground b/9. Classes and Structures.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/9. Classes and Structures.playground/contents.xcplayground +++ b/9. Classes and Structures.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/99. Not The End.playground/contents.xcplayground b/99. Not The End.playground/contents.xcplayground index 4937636..18a12f6 100644 --- a/99. Not The End.playground/contents.xcplayground +++ b/99. Not The End.playground/contents.xcplayground @@ -1,7 +1,7 @@ - + - \ No newline at end of file + diff --git a/99. Not The End.playground/section-1.swift b/99. Not The End.playground/section-1.swift index 428fde7..a5805be 100644 --- a/99. Not The End.playground/section-1.swift +++ b/99. Not The End.playground/section-1.swift @@ -57,29 +57,3 @@ var ohrly = pi.dynamicType.infinity // Happy coding! // // - Paul Nettle - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/99. Not The End.playground/timeline.xctimeline b/99. Not The End.playground/timeline.xctimeline index b2e8d25..9dfd7db 100644 --- a/99. Not The End.playground/timeline.xctimeline +++ b/99. Not The End.playground/timeline.xctimeline @@ -3,7 +3,7 @@ version = "3.0"> + documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=2502&EndingColumnNumber=5&EndingLineNumber=6&StartingColumnNumber=4&StartingLineNumber=6&Timestamp=432601322.717982"> diff --git a/README.md b/README.md index df92eca..5c9e10f 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,8 @@ Learn Apple's Swift programming language interactively through these playgrounds ###What you'll need - XCode 6 (beta 5 or later) and probably a Mac to run it on. + You will need XCode 6.0 GM (or later) or 6.1 Beta 2 (or later) and probably + a Mac to run it on. ###Purpose & Goal