diff --git a/.DS_Store b/.DS_Store
new file mode 100644
index 0000000..650a22c
Binary files /dev/null and b/.DS_Store differ
diff --git a/10. Properties.playground/contents.xcplayground b/10. Properties.playground/contents.xcplayground
index 18a12f6..8e39341 100644
--- a/10. Properties.playground/contents.xcplayground
+++ b/10. Properties.playground/contents.xcplayground
@@ -4,4 +4,4 @@
-
+
\ No newline at end of file
diff --git a/10. Properties.playground/playground.xcworkspace/contents.xcworkspacedata b/10. Properties.playground/playground.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/10. Properties.playground/playground.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/10. Properties.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate b/10. Properties.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..6391435
Binary files /dev/null and b/10. Properties.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/10. Properties.playground/section-1.swift b/10. Properties.playground/section-1.swift
index e63507f..56731ec 100644
--- a/10. Properties.playground/section-1.swift
+++ b/10. Properties.playground/section-1.swift
@@ -1,4 +1,5 @@
// ------------------------------------------------------------------------------------------------
+// Checked September 2016
// Things to know:
//
// * Properties store values in classes, structures and enumerations.
diff --git a/10. Properties.playground/timeline.xctimeline b/10. Properties.playground/timeline.xctimeline
index 48b1d0d..4beb005 100644
--- a/10. Properties.playground/timeline.xctimeline
+++ b/10. Properties.playground/timeline.xctimeline
@@ -3,7 +3,9 @@
version = "3.0">
+ documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=10202&EndingColumnNumber=5&EndingLineNumber=3&StartingColumnNumber=4&StartingLineNumber=3&Timestamp=496707723.358648"
+ selectedRepresentationIndex = "0"
+ shouldTrackSuperviewWidth = "NO">
diff --git a/11. Methods.playground/contents.xcplayground b/11. Methods.playground/contents.xcplayground
index 18a12f6..8e39341 100644
--- a/11. Methods.playground/contents.xcplayground
+++ b/11. Methods.playground/contents.xcplayground
@@ -4,4 +4,4 @@
-
+
\ No newline at end of file
diff --git a/11. Methods.playground/playground.xcworkspace/contents.xcworkspacedata b/11. Methods.playground/playground.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/11. Methods.playground/playground.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/11. Methods.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate b/11. Methods.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..764e784
Binary files /dev/null and b/11. Methods.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/11. Methods.playground/section-1.swift b/11. Methods.playground/section-1.swift
index bbe6559..e4b7fcd 100644
--- a/11. Methods.playground/section-1.swift
+++ b/11. Methods.playground/section-1.swift
@@ -1,4 +1,5 @@
// ------------------------------------------------------------------------------------------------
+// Checked and updated September 2016
// Things to know:
//
// * Methods can be in the form of Instance Methods, which apply to a given instance of a class
@@ -45,7 +46,7 @@ class Counter
// No parameters
func increment()
{
- count++
+ count += 1
}
// One parameter, no external parameter name needed by caller
@@ -80,7 +81,7 @@ class Counter
// Two parameters. Using the external parameter shorthand ("#") to force caller to use
// external parameter name on first parameter and defaulting to shared local/external names
// for the rest.
- func addTwiceWithExternalSpecified2(#first: Int, second: Int)
+ func addTwiceWithExternalSpecified2(first: Int, second: Int)
{
count += first
count += second
@@ -97,12 +98,12 @@ class Counter
// Now let's see how we call each of those functions
var counter = Counter()
counter.increment()
-counter.incrementBy(4)
+counter.incrementBy(amount: 4)
counter.addValueTo(value: 4)
-counter.addTwiceWithExternalImplied(50, second: 4)
+counter.addTwiceWithExternalImplied(first: 50, second: 4)
counter.addTwiceWithExternalSpecified(a: 50, b: 4)
counter.addTwiceWithExternalSpecified2(first: 10, second: 10)
-counter.addTwiceWithExternalSpecified3(10, 10)
+counter.addTwiceWithExternalSpecified3(first: 10, 10)
counter.count
// The 'self' property refers to the current instance of a class, structure or enumeration. For
@@ -160,17 +161,17 @@ struct Point3
// enumeration:
enum TriStateSwitch
{
- case Off, Low, High
+ case off, low, high
mutating func next()
{
switch self
{
- case Off:
- self = Low
- case Low:
- self = High
- case High:
- self = Off
+ case .off:
+ self = .low
+ case .low:
+ self = .high
+ case .high:
+ self = .off
}
}
}
@@ -199,7 +200,7 @@ struct LevelTracker
}
mutating func advanceToLevel(level: Int) -> Bool
{
- if LevelTracker.levelIsUnlocked(level)
+ if LevelTracker.levelIsUnlocked(level: level)
{
currentLevel = level
return true
@@ -212,7 +213,7 @@ struct LevelTracker
}
// To call a type method, use the type name, not the instance name:
-LevelTracker.levelIsUnlocked(3)
+LevelTracker.levelIsUnlocked(level: 3)
// If we attempt to use an instance to call a type method, we'll get an error
var levelTracker = LevelTracker()
@@ -231,4 +232,4 @@ class SomeOtherClass
}
// We call class type methods with the type name just as we do for structures and enumerations:
-SomeOtherClass.isGreaterThan100(105)
+SomeOtherClass.isGreaterThan100(value: 105)
diff --git a/11. Methods.playground/timeline.xctimeline b/11. Methods.playground/timeline.xctimeline
index f894cb8..ad36c1f 100644
--- a/11. Methods.playground/timeline.xctimeline
+++ b/11. Methods.playground/timeline.xctimeline
@@ -3,7 +3,9 @@
version = "3.0">
+ documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=6395&EndingColumnNumber=5&EndingLineNumber=9&StartingColumnNumber=4&StartingLineNumber=9&Timestamp=496707947.258279"
+ selectedRepresentationIndex = "0"
+ shouldTrackSuperviewWidth = "NO">
diff --git a/12. Subscripts.playground/playground.xcworkspace/contents.xcworkspacedata b/12. Subscripts.playground/playground.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/12. Subscripts.playground/playground.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/12. Subscripts.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate b/12. Subscripts.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..fed435b
Binary files /dev/null and b/12. Subscripts.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/13. Inheritance.playground/contents.xcplayground b/13. Inheritance.playground/contents.xcplayground
index 18a12f6..8e39341 100644
--- a/13. Inheritance.playground/contents.xcplayground
+++ b/13. Inheritance.playground/contents.xcplayground
@@ -4,4 +4,4 @@
-
+
\ No newline at end of file
diff --git a/13. Inheritance.playground/playground.xcworkspace/contents.xcworkspacedata b/13. Inheritance.playground/playground.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/13. Inheritance.playground/playground.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/13. Inheritance.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate b/13. Inheritance.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..a41649c
Binary files /dev/null and b/13. Inheritance.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/13. Inheritance.playground/section-1.swift b/13. Inheritance.playground/section-1.swift
index b17743d..c4cbdff 100644
--- a/13. Inheritance.playground/section-1.swift
+++ b/13. Inheritance.playground/section-1.swift
@@ -1,4 +1,5 @@
// ------------------------------------------------------------------------------------------------
+// Checked September 2016
// Things to know:
//
// * There is no default base class for Swift objects. Any class that doesn't derive from
diff --git a/13. Inheritance.playground/timeline.xctimeline b/13. Inheritance.playground/timeline.xctimeline
index 23147a5..4f6fbf6 100644
--- a/13. Inheritance.playground/timeline.xctimeline
+++ b/13. Inheritance.playground/timeline.xctimeline
@@ -3,7 +3,9 @@
version = "3.0">
+ documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=4456&EndingColumnNumber=5&EndingLineNumber=8&StartingColumnNumber=4&StartingLineNumber=8&Timestamp=496755665.442609"
+ selectedRepresentationIndex = "0"
+ shouldTrackSuperviewWidth = "NO">
diff --git a/14a. Initialization.playground/contents.xcplayground b/14a. Initialization.playground/contents.xcplayground
index 18a12f6..8e39341 100644
--- a/14a. Initialization.playground/contents.xcplayground
+++ b/14a. Initialization.playground/contents.xcplayground
@@ -4,4 +4,4 @@
-
+
\ No newline at end of file
diff --git a/14a. Initialization.playground/playground.xcworkspace/contents.xcworkspacedata b/14a. Initialization.playground/playground.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/14a. Initialization.playground/playground.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/14a. Initialization.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate b/14a. Initialization.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..c6fec13
Binary files /dev/null and b/14a. Initialization.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/14a. Initialization.playground/section-1.swift b/14a. Initialization.playground/section-1.swift
index 8638c0a..46a6238 100644
--- a/14a. Initialization.playground/section-1.swift
+++ b/14a. Initialization.playground/section-1.swift
@@ -1,4 +1,5 @@
// ------------------------------------------------------------------------------------------------
+// Checked and updated September 2016
// Things to know:
//
// * Swift provides an initializer (which partially resembles a function) to ensure that every
@@ -67,7 +68,7 @@ let freezingPointOfWater = Celsius(kelvin: 273.15)
// name generation and one that opts out:
struct Color
{
- let red = 0.0, green = 0.0, blue = 0.0
+ var red = 0.0, green = 0.0, blue = 0.0
// This initializer will make use of automatically generated exernal names
init(red: Double, green: Double, blue: Double)
@@ -116,7 +117,7 @@ class SurveyQuestion
class SurveyQuestion2
{
// Default value of "No question"
- let text: String = "No question"
+ var text: String = "No question"
var response: String?
diff --git a/14a. Initialization.playground/timeline.xctimeline b/14a. Initialization.playground/timeline.xctimeline
index 152e9b8..79df9b3 100644
--- a/14a. Initialization.playground/timeline.xctimeline
+++ b/14a. Initialization.playground/timeline.xctimeline
@@ -3,7 +3,9 @@
version = "3.0">
+ documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=7182&EndingColumnNumber=5&EndingLineNumber=10&StartingColumnNumber=4&StartingLineNumber=10&Timestamp=496755767.283091"
+ selectedRepresentationIndex = "0"
+ shouldTrackSuperviewWidth = "NO">
diff --git a/14b. Initializer Chaining.playground/contents.xcplayground b/14b. Initializer Chaining.playground/contents.xcplayground
index 18a12f6..8e39341 100644
--- a/14b. Initializer Chaining.playground/contents.xcplayground
+++ b/14b. Initializer Chaining.playground/contents.xcplayground
@@ -4,4 +4,4 @@
-
+
\ No newline at end of file
diff --git a/14b. Initializer Chaining.playground/playground.xcworkspace/contents.xcworkspacedata b/14b. Initializer Chaining.playground/playground.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/14b. Initializer Chaining.playground/playground.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/14b. Initializer Chaining.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate b/14b. Initializer Chaining.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..ad38696
Binary files /dev/null and b/14b. Initializer Chaining.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/14b. Initializer Chaining.playground/section-1.swift b/14b. Initializer Chaining.playground/section-1.swift
index d4ed131..a003160 100644
--- a/14b. Initializer Chaining.playground/section-1.swift
+++ b/14b. Initializer Chaining.playground/section-1.swift
@@ -1,4 +1,5 @@
// ------------------------------------------------------------------------------------------------
+// Checked and updated September 2016
// Things to know:
//
// * Initializer Chaining refers to the way in which initialization takes place along the class
@@ -190,5 +191,5 @@ struct CheckerBoard
// We can now check our work
var board = CheckerBoard()
-board.squareIsBlackAtRow(1, column: 1) // Should be false
-board.squareIsBlackAtRow(1, column: 2) // Should be true
+board.squareIsBlackAtRow(row: 1, column: 1) // Should be false
+board.squareIsBlackAtRow(row: 1, column: 2) // Should be true
diff --git a/14b. Initializer Chaining.playground/timeline.xctimeline b/14b. Initializer Chaining.playground/timeline.xctimeline
index a497a91..1d94b7d 100644
--- a/14b. Initializer Chaining.playground/timeline.xctimeline
+++ b/14b. Initializer Chaining.playground/timeline.xctimeline
@@ -3,7 +3,9 @@
version = "3.0">
+ documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=7500&EndingColumnNumber=5&EndingLineNumber=27&StartingColumnNumber=4&StartingLineNumber=27&Timestamp=496755871.982254"
+ selectedRepresentationIndex = "0"
+ shouldTrackSuperviewWidth = "NO">
diff --git a/15. Deinitialization.playground/contents.xcplayground b/15. Deinitialization.playground/contents.xcplayground
index 18a12f6..8e39341 100644
--- a/15. Deinitialization.playground/contents.xcplayground
+++ b/15. Deinitialization.playground/contents.xcplayground
@@ -4,4 +4,4 @@
-
+
\ No newline at end of file
diff --git a/15. Deinitialization.playground/playground.xcworkspace/contents.xcworkspacedata b/15. Deinitialization.playground/playground.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/15. Deinitialization.playground/playground.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/15. Deinitialization.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate b/15. Deinitialization.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..3c1e9e8
Binary files /dev/null and b/15. Deinitialization.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/15. Deinitialization.playground/section-1.swift b/15. Deinitialization.playground/section-1.swift
index fec04d3..2412aa3 100644
--- a/15. Deinitialization.playground/section-1.swift
+++ b/15. Deinitialization.playground/section-1.swift
@@ -1,4 +1,5 @@
// ------------------------------------------------------------------------------------------------
+// Checked and updated September 2016
// Things to know:
//
// * Deinitializers are called automatically before a class instance is
@@ -17,9 +18,10 @@
struct Bank
{
static var coinsInBank = 10_000
- static func vendCoins(var numberOfCoinsToVend: Int) -> Int
- {
- numberOfCoinsToVend = min(numberOfCoinsToVend, coinsInBank)
+ static func vendCoins(numberOfCoinsToVend: Int) -> Int
+ {
+ var numberOfCoinsToVend = numberOfCoinsToVend
+ numberOfCoinsToVend = min(numberOfCoinsToVend, coinsInBank)
coinsInBank -= numberOfCoinsToVend
return numberOfCoinsToVend
}
@@ -36,7 +38,7 @@ class Player
init(coins: Int)
{
- coinsInPurse = Bank.vendCoins(coins)
+ coinsInPurse = Bank.vendCoins(numberOfCoinsToVend: coins)
}
func winCoins(coins: Int)
@@ -46,7 +48,7 @@ class Player
deinit
{
- Bank.receiveCoins(coinsInPurse)
+ Bank.receiveCoins(coins: coinsInPurse)
}
}
@@ -57,7 +59,7 @@ playerOne!.coinsInPurse
Bank.coinsInBank
// The Player now wins 2000 coins!
-playerOne!.winCoins(2_000)
+playerOne!.winCoins(coins: 2_000)
playerOne!.coinsInPurse
Bank.coinsInBank
diff --git a/15. Deinitialization.playground/timeline.xctimeline b/15. Deinitialization.playground/timeline.xctimeline
index 96050ff..f9aee7b 100644
--- a/15. Deinitialization.playground/timeline.xctimeline
+++ b/15. Deinitialization.playground/timeline.xctimeline
@@ -3,7 +3,9 @@
version = "3.0">
+ documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=2044&EndingColumnNumber=5&EndingLineNumber=2&StartingColumnNumber=4&StartingLineNumber=1&Timestamp=496756034.689658"
+ selectedRepresentationIndex = "0"
+ shouldTrackSuperviewWidth = "NO">
diff --git a/18. Type Casting.playground/contents.xcplayground b/18. Type Casting.playground/contents.xcplayground
index 18a12f6..8e39341 100644
--- a/18. Type Casting.playground/contents.xcplayground
+++ b/18. Type Casting.playground/contents.xcplayground
@@ -4,4 +4,4 @@
-
+
\ No newline at end of file
diff --git a/18. Type Casting.playground/playground.xcworkspace/contents.xcworkspacedata b/18. Type Casting.playground/playground.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/18. Type Casting.playground/playground.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/18. Type Casting.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate b/18. Type Casting.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..f6b62fb
Binary files /dev/null and b/18. Type Casting.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/18. Type Casting.playground/section-1.swift b/18. Type Casting.playground/section-1.swift
index 0d8ce0d..ea0b694 100644
--- a/18. Type Casting.playground/section-1.swift
+++ b/18. Type Casting.playground/section-1.swift
@@ -1,4 +1,5 @@
// ------------------------------------------------------------------------------------------------
+// Checked and updated September 2016
// Things to know:
//
// * Type casting allows us to check the type of an instance and/or treat that instance as a
@@ -60,8 +61,8 @@ var movieCount = 0
var songCount = 0
for item in library
{
- if item is Movie { ++movieCount }
- else if item is Song { ++songCount }
+ if item is Movie { movieCount += 1 }
+ else if item is Song { songCount += 1 }
}
// Our final Movie and Song counts:
@@ -122,12 +123,12 @@ let someObjects: [AnyObject] =
// Let's see how we would use the someObjects array:
for object: AnyObject in someObjects
{
- let movie = object as Movie
+ let movie = object as! Movie
"Movie: '\(movie.name)' was directed by \(movie.director)"
}
// Alternatively, we can downcast the array itself rather than each item:
-var someMovies = someObjects as [Movie]
+var someMovies = someObjects as! [Movie]
for movie in someMovies
{
"Movie: '\(movie.name)' was directed by \(movie.director)"
@@ -135,7 +136,7 @@ for movie in someMovies
// Finally, we can avoid the additional local variable and performt he downcast right inside
// the loop structure:
-for movie in someObjects as [Movie]
+for movie in someObjects as! [Movie]
{
"Movie: '\(movie.name)' was directed by \(movie.director)"
}
diff --git a/18. Type Casting.playground/timeline.xctimeline b/18. Type Casting.playground/timeline.xctimeline
index efb6837..156d4a5 100644
--- a/18. Type Casting.playground/timeline.xctimeline
+++ b/18. Type Casting.playground/timeline.xctimeline
@@ -3,7 +3,9 @@
version = "3.0">
+ documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=6545&EndingColumnNumber=5&EndingLineNumber=3&StartingColumnNumber=4&StartingLineNumber=3&Timestamp=496964976.489721"
+ selectedRepresentationIndex = "0"
+ shouldTrackSuperviewWidth = "NO">
diff --git a/19. Nested Types.playground/contents.xcplayground b/19. Nested Types.playground/contents.xcplayground
index 18a12f6..8e39341 100644
--- a/19. Nested Types.playground/contents.xcplayground
+++ b/19. Nested Types.playground/contents.xcplayground
@@ -4,4 +4,4 @@
-
+
\ No newline at end of file
diff --git a/19. Nested Types.playground/playground.xcworkspace/contents.xcworkspacedata b/19. Nested Types.playground/playground.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/19. Nested Types.playground/playground.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/19. Nested Types.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate b/19. Nested Types.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..8802de4
Binary files /dev/null and b/19. Nested Types.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/19. Nested Types.playground/section-1.swift b/19. Nested Types.playground/section-1.swift
index e34d5b4..1a0173c 100644
--- a/19. Nested Types.playground/section-1.swift
+++ b/19. Nested Types.playground/section-1.swift
@@ -1,4 +1,5 @@
// ------------------------------------------------------------------------------------------------
+// Updated September 2016
// Things to know:
//
// * Nested types are utility classes and structures that are declared within other classes,
@@ -21,14 +22,14 @@ struct BlackjackCard
// Nested Suit enumeration
enum Suit: Character
{
- case Spades = "♠", Hearts = "♡", Diamonds = "♢", Clubs = "♣"
+ case spades = "♠", hearts = "♡", diamonds = "♢", clubs = "♣"
}
// Nested Rank enumeration
enum Rank: Int
{
- case Two = 2, Three, Four, Five, Six, Seven, Eight, Nine, Ten
- case Jack, Queen, King, Ace
+ case two = 2, three, four, five, six, seven, eight, nine, ten
+ case jack, queen, king, ace
// A rank can possibly have two values (for the Ace), so we'll use this structure
// to contain those two values. We could just as well use a Tuple, but we're showcasing
@@ -49,9 +50,9 @@ struct BlackjackCard
{
switch self
{
- case .Ace:
+ case .ace:
return Values(first: 1, second: 11)
- case .Jack, .Queen, .King:
+ case .jack, .queen, .king:
return Values(first: 10, second: nil)
default:
return Values(first: self.rawValue, second: nil)
@@ -80,8 +81,8 @@ struct BlackjackCard
// Also note that since the initializer knows thet type of each member being initialized (both of
// which are enumerations) we can use the shorthand method (.Something) for each member's initial
// value.
-let theAceOfSpades = BlackjackCard(rank: .Ace, suit: .Spades)
+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.rawValue )
+let heartsSymbol = String( BlackjackCard.Suit.hearts.rawValue )
diff --git a/19. Nested Types.playground/timeline.xctimeline b/19. Nested Types.playground/timeline.xctimeline
index 4d92167..caead57 100644
--- a/19. Nested Types.playground/timeline.xctimeline
+++ b/19. Nested Types.playground/timeline.xctimeline
@@ -3,7 +3,9 @@
version = "3.0">
+ documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=3073&EndingColumnNumber=5&EndingLineNumber=3&StartingColumnNumber=4&StartingLineNumber=3&Timestamp=496965170.846613"
+ selectedRepresentationIndex = "0"
+ shouldTrackSuperviewWidth = "NO">
diff --git a/1a. The Basics.playground/contents.xcplayground b/1a. The Basics.playground/contents.xcplayground
index 18a12f6..8e39341 100644
--- a/1a. The Basics.playground/contents.xcplayground
+++ b/1a. The Basics.playground/contents.xcplayground
@@ -4,4 +4,4 @@
-
+
\ No newline at end of file
diff --git a/1a. The Basics.playground/playground.xcworkspace/contents.xcworkspacedata b/1a. The Basics.playground/playground.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/1a. The Basics.playground/playground.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/1a. The Basics.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate b/1a. The Basics.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..a55396f
Binary files /dev/null and b/1a. The Basics.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/1a. The Basics.playground/section-1.swift b/1a. The Basics.playground/section-1.swift
index 1dd68fd..4dbe045 100644
--- a/1a. The Basics.playground/section-1.swift
+++ b/1a. The Basics.playground/section-1.swift
@@ -58,7 +58,7 @@ let 🐶🐮 = "dogcow"
// You can print a value using println
let fiveHundred = 500
-println("The current value of fiveHundred is: \(fiveHundred)")
+print("The current value of fiveHundred is: \(fiveHundred)")
// Since we're using Playgrounds, we'll just put the raw string on the line which is an expression
// that evaluates to itself, printing the result in the right-hand pane in the playground, like so:
diff --git a/1a. The Basics.playground/timeline.xctimeline b/1a. The Basics.playground/timeline.xctimeline
index ae188c4..27cd78c 100644
--- a/1a. The Basics.playground/timeline.xctimeline
+++ b/1a. The Basics.playground/timeline.xctimeline
@@ -3,10 +3,14 @@
version = "3.0">
+ documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=8817&EndingColumnNumber=5&EndingLineNumber=4&StartingColumnNumber=4&StartingLineNumber=4&Timestamp=496688334.840134"
+ selectedRepresentationIndex = "0"
+ shouldTrackSuperviewWidth = "NO">
+ documentLocation = "#CharacterRangeLen=17&CharacterRangeLoc=7994&EndingColumnNumber=21&EndingLineNumber=223&StartingColumnNumber=4&StartingLineNumber=223&Timestamp=496688334.842094"
+ selectedRepresentationIndex = "0"
+ shouldTrackSuperviewWidth = "NO">
diff --git a/1b. Type alliases.playground/contents.xcplayground b/1b. Type alliases.playground/contents.xcplayground
index 18a12f6..8e39341 100644
--- a/1b. Type alliases.playground/contents.xcplayground
+++ b/1b. Type alliases.playground/contents.xcplayground
@@ -4,4 +4,4 @@
-
+
\ No newline at end of file
diff --git a/1b. Type alliases.playground/playground.xcworkspace/contents.xcworkspacedata b/1b. Type alliases.playground/playground.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/1b. Type alliases.playground/playground.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/1b. Type alliases.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate b/1b. Type alliases.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..3b68bbe
Binary files /dev/null and b/1b. Type alliases.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/1b. Type alliases.playground/section-1.swift b/1b. Type alliases.playground/section-1.swift
index 4c999bc..521a38a 100644
--- a/1b. Type alliases.playground/section-1.swift
+++ b/1b. Type alliases.playground/section-1.swift
@@ -1,4 +1,5 @@
// ------------------------------------------------------------------------------------------------
+// Last checked September 2016
// Things to know:
//
// * Type Aliases allow you to provide a different name for types,
diff --git a/1b. Type alliases.playground/timeline.xctimeline b/1b. Type alliases.playground/timeline.xctimeline
index 74fb0a0..2372d0d 100644
--- a/1b. Type alliases.playground/timeline.xctimeline
+++ b/1b. Type alliases.playground/timeline.xctimeline
@@ -3,7 +3,9 @@
version = "3.0">
+ documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=653&EndingColumnNumber=5&EndingLineNumber=4&StartingColumnNumber=4&StartingLineNumber=4&Timestamp=496703717.484851"
+ selectedRepresentationIndex = "0"
+ shouldTrackSuperviewWidth = "NO">
diff --git a/1c. Tuples.playground/contents.xcplayground b/1c. Tuples.playground/contents.xcplayground
index 18a12f6..8e39341 100644
--- a/1c. Tuples.playground/contents.xcplayground
+++ b/1c. Tuples.playground/contents.xcplayground
@@ -4,4 +4,4 @@
-
+
\ No newline at end of file
diff --git a/1c. Tuples.playground/playground.xcworkspace/contents.xcworkspacedata b/1c. Tuples.playground/playground.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/1c. Tuples.playground/playground.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/1c. Tuples.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate b/1c. Tuples.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..f2024eb
Binary files /dev/null and b/1c. Tuples.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/1c. Tuples.playground/section-1.swift b/1c. Tuples.playground/section-1.swift
index 456f8c6..5eb97a1 100644
--- a/1c. Tuples.playground/section-1.swift
+++ b/1c. Tuples.playground/section-1.swift
@@ -1,4 +1,5 @@
// ------------------------------------------------------------------------------------------------
+// Checked September 2016
// Things to know:
//
// * Tuples are groups of values combined into a single, compound value
diff --git a/1c. Tuples.playground/timeline.xctimeline b/1c. Tuples.playground/timeline.xctimeline
deleted file mode 100644
index bf468af..0000000
--- a/1c. Tuples.playground/timeline.xctimeline
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
diff --git a/1d. Optionals.playground/contents.xcplayground b/1d. Optionals.playground/contents.xcplayground
index 18a12f6..8e39341 100644
--- a/1d. Optionals.playground/contents.xcplayground
+++ b/1d. Optionals.playground/contents.xcplayground
@@ -4,4 +4,4 @@
-
+
\ No newline at end of file
diff --git a/1d. Optionals.playground/playground.xcworkspace/contents.xcworkspacedata b/1d. Optionals.playground/playground.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/1d. Optionals.playground/playground.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/1d. Optionals.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate b/1d. Optionals.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..4704b91
Binary files /dev/null and b/1d. Optionals.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/1d. Optionals.playground/section-1.swift b/1d. Optionals.playground/section-1.swift
index 5383b35..758fdd4 100644
--- a/1d. Optionals.playground/section-1.swift
+++ b/1d. Optionals.playground/section-1.swift
@@ -1,4 +1,5 @@
// ------------------------------------------------------------------------------------------------
+// Checked September 2016
// Things to know:
//
// * An optional value is a stored value that can either hold a value or "no value at all"
@@ -10,7 +11,7 @@
// An optional declaration adds a "?" immediately after the explicit type. The following line
// defines a value 'someOptional' that can either hold an Int or no value at all. In this case
// we set an optional Int value to .None (similar to nil)
-let someOptional: Int? = .None
+let someOptional: Int? = .none
// Let's try to convert a String to an Int
//
@@ -21,14 +22,14 @@ let someOptional: Int? = .None
//
// Here's an optional in action
let notNumber = "abc"
-let failedConversion = notNumber.toInt()
+let failedConversion = Int(notNumber)
// Notice how failedConversion is 'nil', even though it's an Int
failedConversion
// Let's carry on with a successful conversion
let possibleNumber = "123"
-var optionalConvertedNumber = possibleNumber.toInt()
+var optionalConvertedNumber = Int(possibleNumber)
// This one worked
optionalConvertedNumber
@@ -44,8 +45,8 @@ let unwrapped = optionalConvertedNumber // 'unwrapped' is another optional
// let's not let that stop us from learning this little detail.
//
// These two lines are of equivalent types:
-let optionalA: String? = .None
-let optionalB: Optional = .None
+let optionalA: String? = .none
+let optionalB: Optional = .none
// ------------------------------------------------------------------------------------------------
// Unwrapping
@@ -65,7 +66,7 @@ let unwrappedInt = optionalConvertedNumber!
// Implicit unwrapping isn't very safe because if the optional doesn't hold a value, it will
// generate a runtime error. To verify that is's safe, you can check the optional with an if
// statement.
-if optionalConvertedNumber != .None
+if optionalConvertedNumber != .none
{
// It's now safe to force-unwrap because we KNOW it has a value
let anotherUnwrappedInt = optionalConvertedNumber!
@@ -99,15 +100,15 @@ else
// We can still use optional binding to bind to another optional value, if we do so explicitly
// by specifying the type of the stored value that we're binding to.
-if let optionalIntValue:Int? = optionalConvertedNumber
+if let optionalIntValue:Int = optionalConvertedNumber
{
// 'optionalIntValue' is still an optional, but it's known to be safe. We can still check
// it here, though, because it's still an optional. If it weren't optional, this if statement
// wouldn't compile:
- if optionalIntValue != .None
+ if optionalIntValue != .none
{
// 'optionalIntValue' is optional, so we still use the force-unwrap here:
- "intValue is optional, but has the value \(optionalIntValue!)"
+ "intValue is optional, but has the value \(optionalIntValue)"
}
}
@@ -115,7 +116,7 @@ if let optionalIntValue:Int? = optionalConvertedNumber
optionalConvertedNumber = nil
// Now if we check it, we see that it holds no value:
-if optionalConvertedNumber != .None
+if optionalConvertedNumber != .none
{
"optionalConvertedNumber holds a value (\(optionalConvertedNumber))! (this should not happen)"
}
diff --git a/1d. Optionals.playground/timeline.xctimeline b/1d. Optionals.playground/timeline.xctimeline
index ba175f8..9213b1d 100644
--- a/1d. Optionals.playground/timeline.xctimeline
+++ b/1d. Optionals.playground/timeline.xctimeline
@@ -3,7 +3,9 @@
version = "3.0">
+ documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=6968&EndingColumnNumber=5&EndingLineNumber=3&StartingColumnNumber=4&StartingLineNumber=3&Timestamp=496704474.911197"
+ selectedRepresentationIndex = "0"
+ shouldTrackSuperviewWidth = "NO">
diff --git a/1e. Assertions.playground/contents.xcplayground b/1e. Assertions.playground/contents.xcplayground
index 18a12f6..8e39341 100644
--- a/1e. Assertions.playground/contents.xcplayground
+++ b/1e. Assertions.playground/contents.xcplayground
@@ -4,4 +4,4 @@
-
+
\ No newline at end of file
diff --git a/1e. Assertions.playground/playground.xcworkspace/contents.xcworkspacedata b/1e. Assertions.playground/playground.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/1e. Assertions.playground/playground.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/1e. Assertions.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate b/1e. Assertions.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..e2f883b
Binary files /dev/null and b/1e. Assertions.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/1e. Assertions.playground/section-1.swift b/1e. Assertions.playground/section-1.swift
index 460e628..8aa839a 100644
--- a/1e. Assertions.playground/section-1.swift
+++ b/1e. Assertions.playground/section-1.swift
@@ -1,4 +1,5 @@
// ------------------------------------------------------------------------------------------------
+// Checked September 2016
// Things to know:
//
// * Assertions only trigger in debug mode and not in published builds
diff --git a/1e. Assertions.playground/timeline.xctimeline b/1e. Assertions.playground/timeline.xctimeline
index bd6221e..af911ef 100644
--- a/1e. Assertions.playground/timeline.xctimeline
+++ b/1e. Assertions.playground/timeline.xctimeline
@@ -3,7 +3,9 @@
version = "3.0">
+ documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=602&EndingColumnNumber=5&EndingLineNumber=3&StartingColumnNumber=4&StartingLineNumber=3&Timestamp=496704541.727928"
+ selectedRepresentationIndex = "0"
+ shouldTrackSuperviewWidth = "NO">
diff --git a/2. Basic operations.playground/contents.xcplayground b/2. Basic operations.playground/contents.xcplayground
index 18a12f6..8e39341 100644
--- a/2. Basic operations.playground/contents.xcplayground
+++ b/2. Basic operations.playground/contents.xcplayground
@@ -4,4 +4,4 @@
-
+
\ No newline at end of file
diff --git a/2. Basic operations.playground/playground.xcworkspace/contents.xcworkspacedata b/2. Basic operations.playground/playground.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/2. Basic operations.playground/playground.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/2. Basic operations.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate b/2. Basic operations.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..f42471b
Binary files /dev/null and b/2. Basic operations.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/2. Basic operations.playground/section-1.swift b/2. Basic operations.playground/section-1.swift
index 6bbaeda..80528d1 100644
--- a/2. Basic operations.playground/section-1.swift
+++ b/2. Basic operations.playground/section-1.swift
@@ -1,4 +1,5 @@
// ------------------------------------------------------------------------------------------------
+// Checked and updated September 2016
// Things to know:
//
// * Assuming knowledge of C here, so a lot will be left out that is the the same, such as
@@ -28,7 +29,8 @@ y
// (%) which is not to be confused with modulo. They work differently because of the way remainders
// are calculated for negative numbers and can be used with floating point values.
var c = a / b // Floatng point result
-var d = a % b // Floating point remainder
+//var d = a % b // Floating point remainder *** % is no longer supported for modulus in Swift 3 -> use truncatingRemainder ***
+var d = a.truncatingRemainder(dividingBy: b)
// ------------------------------------------------------------------------------------------------
// Range operators
@@ -53,7 +55,7 @@ for i in 1...10
// Unary, Binary and Ternary operators
//
// Unary prefix operators appear before their taget. Here we increment a then negate it:
-++a
+a += 1
a = -a
// You can also use the uniary + operator, though it doesn't do anything
@@ -67,7 +69,7 @@ var truefalse = true
truefalse = !truefalse
// Unary postfix operators appear after their target: i++
-a--
+a -= 1
a
// Binary operators are infix because they appear between to targets
diff --git a/2. Basic operations.playground/timeline.xctimeline b/2. Basic operations.playground/timeline.xctimeline
index 9a87e18..adc86da 100644
--- a/2. Basic operations.playground/timeline.xctimeline
+++ b/2. Basic operations.playground/timeline.xctimeline
@@ -3,7 +3,9 @@
version = "3.0">
+ documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=3596&EndingColumnNumber=5&EndingLineNumber=3&StartingColumnNumber=4&StartingLineNumber=3&Timestamp=496704952.717255"
+ selectedRepresentationIndex = "0"
+ shouldTrackSuperviewWidth = "NO">
diff --git a/20. Extensions.playground/contents.xcplayground b/20. Extensions.playground/contents.xcplayground
index 18a12f6..8e39341 100644
--- a/20. Extensions.playground/contents.xcplayground
+++ b/20. Extensions.playground/contents.xcplayground
@@ -4,4 +4,4 @@
-
+
\ No newline at end of file
diff --git a/20. Extensions.playground/playground.xcworkspace/contents.xcworkspacedata b/20. Extensions.playground/playground.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/20. Extensions.playground/playground.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/20. Extensions.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate b/20. Extensions.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..a6568ff
Binary files /dev/null and b/20. Extensions.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/20. Extensions.playground/section-1.swift b/20. Extensions.playground/section-1.swift
index 19b54e1..2d60b0a 100644
--- a/20. Extensions.playground/section-1.swift
+++ b/20. Extensions.playground/section-1.swift
@@ -1,4 +1,5 @@
// ------------------------------------------------------------------------------------------------
+// Updated September 2016
// Things to know:
//
// * Similar to Objective-C categories, extensions allow you to add functionality to an existing
@@ -108,7 +109,7 @@ extension Int
{
func repititions(task: () -> ())
{
- for i in 0..
+ documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=5390&EndingColumnNumber=5&EndingLineNumber=3&StartingColumnNumber=4&StartingLineNumber=3&Timestamp=496965583.146364"
+ selectedRepresentationIndex = "0"
+ shouldTrackSuperviewWidth = "NO">
diff --git a/21. Protocols.playground/contents.xcplayground b/21. Protocols.playground/contents.xcplayground
index 18a12f6..8e39341 100644
--- a/21. Protocols.playground/contents.xcplayground
+++ b/21. Protocols.playground/contents.xcplayground
@@ -4,4 +4,4 @@
-
+
\ No newline at end of file
diff --git a/21. Protocols.playground/playground.xcworkspace/contents.xcworkspacedata b/21. Protocols.playground/playground.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/21. Protocols.playground/playground.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/21. Protocols.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate b/21. Protocols.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..e80dee9
Binary files /dev/null and b/21. Protocols.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/21. Protocols.playground/section-1.swift b/21. Protocols.playground/section-1.swift
index 6f1abc6..4163c3c 100644
--- a/21. Protocols.playground/section-1.swift
+++ b/21. Protocols.playground/section-1.swift
@@ -1,4 +1,5 @@
// ------------------------------------------------------------------------------------------------
+// Updated September 2016
// Things to know:
//
// * Protocols define a required set of functionality (including methods and properties) for a
@@ -44,6 +45,9 @@
//
// Let's take a look at a simple protocol. As you'll see, we only need to define the properties
// in terms of 'get' and 'set' and do not provide the actual functionality.
+
+import Foundation
+
protocol someProtocolForProperties
{
// A read/write property
@@ -54,7 +58,7 @@ protocol someProtocolForProperties
// A type property always uses 'class'. This is the case even if adopted by a structure or
// enumeration which will use 'static' when conforming to the protocol's property.
- class var someTypeProperty: Int { get set }
+ static var someTypeProperty: Int { get set }
}
// Let's create a more practical protocol that we can actually conform to:
@@ -85,7 +89,7 @@ class Starship: FullyNamed
var fullName: String
{
- return (prefix != .None ? prefix! + " " : "") + name
+ return (prefix != .none ? prefix! + " " : "") + name
}
}
@@ -126,7 +130,7 @@ class LinearCongruentialGenerator: RandomNumberGenerator
var c = 29573.0
func random() -> Double
{
- lastRandom = ((lastRandom * a + c) % m)
+ lastRandom = (lastRandom * a + c).truncatingRemainder(dividingBy: m)
return lastRandom / m
}
}
@@ -299,13 +303,13 @@ struct Individual: Named, Aged
// Here, we can see the protocol composition at work as the parameter into the wishHappyBirthday()
// function:
-func wishHappyBirthday(celebrator: protocol) -> String
+func wishHappyBirthday(celebrator: Named & Aged) -> String
{
return "Happy Birthday \(celebrator.name) - you're \(celebrator.age)!"
}
// If we call the member, we can see the celebratory wish for this individual:
-wishHappyBirthday(Individual(name: "Bill", age: 31))
+wishHappyBirthday(celebrator: Individual(name: "Bill", age: 31))
// ------------------------------------------------------------------------------------------------
// Checking for Protocol Conformance
@@ -381,26 +385,26 @@ objects[2] is HasArea
// Here's another simple protocol that uses optional requrements:
@objc protocol CounterDataSource
{
- optional func incrementForCount(count: Int) -> Int
- optional var fixedIncrement: Int { get }
+ @objc optional func incrementForCount(count: Int) -> Int
+ @objc optional var fixedIncrement: Int { get }
}
// In the class below, we'll see that checking to see if an instance conforms to a specific
// requirement is similar to checking for (and accessing) optionals. We'll use optional chaining
// for these optional reqirements:
-@objc class Counter
+class Counter
{
var count = 0
var dataSource: CounterDataSource?
func increment()
{
// Does the dataSource conform to the incrementForCount method?
- if let amount = dataSource?.incrementForCount?(count)
+ if let amount = dataSource?.incrementForCount?(count: count)
{
count += amount
}
// If not, does it conform to the fixedIncrement variable requirement?
- else if let amount = dataSource?.fixedIncrement?
+ else if let amount = dataSource?.fixedIncrement
{
count += amount
}
diff --git a/21. Protocols.playground/timeline.xctimeline b/21. Protocols.playground/timeline.xctimeline
index e56777b..f02786b 100644
--- a/21. Protocols.playground/timeline.xctimeline
+++ b/21. Protocols.playground/timeline.xctimeline
@@ -3,7 +3,9 @@
version = "3.0">
+ documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=13169&EndingColumnNumber=5&EndingLineNumber=3&StartingColumnNumber=4&StartingLineNumber=3&Timestamp=496966090.588793"
+ selectedRepresentationIndex = "0"
+ shouldTrackSuperviewWidth = "NO">
diff --git a/22. Generics.playground/contents.xcplayground b/22. Generics.playground/contents.xcplayground
index 18a12f6..8e39341 100644
--- a/22. Generics.playground/contents.xcplayground
+++ b/22. Generics.playground/contents.xcplayground
@@ -4,4 +4,4 @@
-
+
\ No newline at end of file
diff --git a/22. Generics.playground/playground.xcworkspace/contents.xcworkspacedata b/22. Generics.playground/playground.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/22. Generics.playground/playground.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/22. Generics.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate b/22. Generics.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..9e67260
Binary files /dev/null and b/22. Generics.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/22. Generics.playground/section-1.swift b/22. Generics.playground/section-1.swift
index 3bd203c..abddde8 100644
--- a/22. Generics.playground/section-1.swift
+++ b/22. Generics.playground/section-1.swift
@@ -1,4 +1,5 @@
// ------------------------------------------------------------------------------------------------
+// Updated September 2016
// Things to know:
//
// * Generics allow flexible, reusable functions and types that can work with any type, subject
@@ -12,7 +13,7 @@
// The problem that Generics solve
//
// Consider the following function which can swap two Ints.
-func swapTwoInts(inout a: Int, inout b: Int)
+func swapTwoInts( a: inout Int, b: inout Int)
{
let tmp = a
a = b
@@ -21,7 +22,7 @@ func swapTwoInts(inout a: Int, inout b: Int)
// What if we wanted to swap Strings? Or any other type? We would need to write a lot of different
// swap functions. Instead, let's use Generics. Consider the following generic function:
-func swapTwoValues(inout a: T, inout b: T)
+func swapTwoValues( a: inout T, b: inout T)
{
let tmp = a
a = b
@@ -53,19 +54,19 @@ func swapTwoValues(inout a: T, inout b: T)
// Let's call it a few times to see it in action:
var aInt = 3
var bInt = 4
-swapTwoValues(&aInt, &bInt)
+swapTwoValues(a: &aInt, b: &bInt)
aInt
bInt
var aDouble = 3.3
var bDouble = 4.4
-swapTwoValues(&aDouble, &bDouble)
+swapTwoValues(a: &aDouble, b: &bDouble)
aDouble
bDouble
var aString = "three"
var bString = "four"
-swapTwoValues(&aString, &bString)
+swapTwoValues(a: &aString, b: &bString)
aString
bString
@@ -95,10 +96,10 @@ struct Stack
// Let's use our new Stack:
var stackOfStrings = Stack()
-stackOfStrings.push("uno")
-stackOfStrings.push("dos")
-stackOfStrings.push("tres")
-stackOfStrings.push("cuatro")
+stackOfStrings.push(item: "uno")
+stackOfStrings.push(item: "dos")
+stackOfStrings.push(item: "tres")
+stackOfStrings.push(item: "cuatro")
stackOfStrings.pop()
stackOfStrings.pop()
@@ -135,7 +136,7 @@ func doSomethingWithKeyValue(someKey: KeyType, som
// criteria.
func findIndex(array: [T], valueToFind: T) -> Int?
{
- for (index, value) in enumerate(array)
+ for (index, value) in array.enumerated()
{
if value == valueToFind
{
@@ -146,8 +147,8 @@ func findIndex(array: [T], valueToFind: T) -> Int?
}
// Let's try a few different inputs
-let doubleIndex = findIndex([3.14159, 0.1, 0.25], 9.3)
-let stringIndex = findIndex(["Mike", "Malcolm", "Andrea"], "Andrea")
+let doubleIndex = findIndex(array: [3.14159, 0.1, 0.25], valueToFind: 9.3)
+let stringIndex = findIndex(array: ["Mike", "Malcolm", "Andrea"], valueToFind: "Andrea")
// ------------------------------------------------------------------------------------------------
// Associated types
@@ -158,7 +159,7 @@ let stringIndex = findIndex(["Mike", "Malcolm", "Andrea"], "Andrea")
// Let's jump right into some code:
protocol Container
{
- typealias ItemType
+ associatedtype ItemType
mutating func append(item: ItemType)
var count: Int { get }
subscript(i: Int) -> ItemType { get }
@@ -189,9 +190,9 @@ struct StackContainer : Container
// Below, we conform to the protocol
- mutating func append(item: T)
- {
- self.push(item)
+ mutating func append(item: T)
+ {
+ self.push(item: item)
}
var count: Int
{
@@ -210,17 +211,17 @@ struct StackContainer : Container
//
// Let's verify our work:
var stringStack = StackContainer()
-stringStack.push("Albert")
-stringStack.push("Andrew")
-stringStack.push("Betty")
-stringStack.push("Jacob")
+stringStack.push(item: "Albert")
+stringStack.push(item: "Andrew")
+stringStack.push(item: "Betty")
+stringStack.push(item: "Jacob")
stringStack.pop()
stringStack.count
var doubleStack = StackContainer()
-doubleStack.push(3.14159)
-doubleStack.push(42.0)
-doubleStack.push(1_000_000)
+doubleStack.push(item: 3.14159)
+doubleStack.push(item: 42.0)
+doubleStack.push(item: 1_000_000)
doubleStack.pop()
doubleStack.count
@@ -241,8 +242,8 @@ extension Array: Container {}
// Let's take a look at a where clause in action. We'll define a function that works on two
// different containers that that must contain the same type of item.
func allItemsMatch
-
- (someContainer: C1, anotherContainer: C2) -> Bool
+
+ (someContainer: C1, anotherContainer: C2) -> Bool where C1.ItemType == C2.ItemType, C1.ItemType: Equatable
{
// Check that both containers contain the same number of items
if someContainer.count != anotherContainer.count
@@ -276,11 +277,11 @@ func allItemsMatch
//
// Let's test this out by passing the same value for each parameter which should definitely
// return true:
-allItemsMatch(doubleStack, doubleStack)
+allItemsMatch(someContainer: doubleStack, anotherContainer: doubleStack)
// We can compare stringStack against an array of type String[] because we've extended Swift's
// Array type to conform to our Container protocol:
-allItemsMatch(stringStack, ["Alpha", "Beta", "Theta"])
+allItemsMatch(someContainer: stringStack, anotherContainer: ["Alpha", "Beta", "Theta"])
// Finally, if we attempt to call allItemsMatch with a stringStack and a doubleStack, we would get
// a compiler error because they do not store the same ItemType as defined in the function's
diff --git a/22. Generics.playground/timeline.xctimeline b/22. Generics.playground/timeline.xctimeline
index bcaf52b..5e9413f 100644
--- a/22. Generics.playground/timeline.xctimeline
+++ b/22. Generics.playground/timeline.xctimeline
@@ -3,7 +3,9 @@
version = "3.0">
+ documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=2478&EndingColumnNumber=5&EndingLineNumber=3&StartingColumnNumber=4&StartingLineNumber=3&Timestamp=496966547.493615"
+ selectedRepresentationIndex = "0"
+ shouldTrackSuperviewWidth = "NO">
diff --git a/23. Advanced Operators.playground/contents.xcplayground b/23. Advanced Operators.playground/contents.xcplayground
index 18a12f6..8e39341 100644
--- a/23. Advanced Operators.playground/contents.xcplayground
+++ b/23. Advanced Operators.playground/contents.xcplayground
@@ -4,4 +4,4 @@
-
+
\ No newline at end of file
diff --git a/23. Advanced Operators.playground/playground.xcworkspace/contents.xcworkspacedata b/23. Advanced Operators.playground/playground.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/23. Advanced Operators.playground/playground.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/23. Advanced Operators.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate b/23. Advanced Operators.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..fbf4ab6
Binary files /dev/null and b/23. Advanced Operators.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/23. Advanced Operators.playground/section-1.swift b/23. Advanced Operators.playground/section-1.swift
index 30d53d8..6deca38 100644
--- a/23. Advanced Operators.playground/section-1.swift
+++ b/23. Advanced Operators.playground/section-1.swift
@@ -1,4 +1,5 @@
// ------------------------------------------------------------------------------------------------
+// Updated September 2016
// Things to know:
//
// * Arithmetic operators in Swift do not automatically overflow. Adding two values that overflow
@@ -81,7 +82,7 @@ var aZero: Int8 = someValue - someValue
var overflowAdd: Int8 = someValue &+ someValue
var underflowSub: Int8 = -someValue &- someValue
var overflowMul: Int8 = someValue &* someValue
-var divByZero: Int8 = 100 &/ aZero
+var divByZero: Int8 = 100 / aZero
var remainderDivByZero: Int8 = 100 &% aZero
// ------------------------------------------------------------------------------------------------
@@ -144,15 +145,15 @@ c = -a
// they are also @assigmnent operators (and make use of inout for the parameter.)
//
// Let's take a look:
-prefix func ++ (inout vector: Vector2D) -> Vector2D
+prefix func ++ ( vector: inout Vector2D) -> Vector2D
{
vector = vector + Vector2D(x: 1.0, y: 1.0)
return vector
}
-postfix func ++ (inout vector: Vector2D) -> Vector2D
+postfix func ++ ( vector: inout Vector2D) -> Vector2D
{
- var previous = vector;
+ let previous = vector;
vector = vector + Vector2D(x: 1.0, y: 1.0)
return previous
}
@@ -205,10 +206,10 @@ func != (left: Vector2D, right: Vector2D) -> Bool
// 'operator' keyword, folowed by either 'prefix', 'postfix' or 'infix':
//
// Swift meet operator, operator meet swift:
-prefix operator +++ {}
+prefix operator +++
// Now we can declare our new operator:
-prefix func +++ (inout vector: Vector2D) -> Vector2D
+prefix func +++ ( vector: inout Vector2D) -> Vector2D
{
vector = vector + vector
return vector
diff --git a/23. Advanced Operators.playground/timeline.xctimeline b/23. Advanced Operators.playground/timeline.xctimeline
index f944334..1f5bd86 100644
--- a/23. Advanced Operators.playground/timeline.xctimeline
+++ b/23. Advanced Operators.playground/timeline.xctimeline
@@ -3,7 +3,9 @@
version = "3.0">
+ documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=10279&EndingColumnNumber=5&EndingLineNumber=3&StartingColumnNumber=4&StartingLineNumber=3&Timestamp=496967020.24943"
+ selectedRepresentationIndex = "0"
+ shouldTrackSuperviewWidth = "NO">
diff --git a/3. Strings and Characters.playground/contents.xcplayground b/3. Strings and Characters.playground/contents.xcplayground
index 18a12f6..8e39341 100644
--- a/3. Strings and Characters.playground/contents.xcplayground
+++ b/3. Strings and Characters.playground/contents.xcplayground
@@ -4,4 +4,4 @@
-
+
\ No newline at end of file
diff --git a/3. Strings and Characters.playground/playground.xcworkspace/contents.xcworkspacedata b/3. Strings and Characters.playground/playground.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/3. Strings and Characters.playground/playground.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/3. Strings and Characters.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate b/3. Strings and Characters.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..0d46fd9
Binary files /dev/null and b/3. Strings and Characters.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/3. Strings and Characters.playground/section-1.swift b/3. Strings and Characters.playground/section-1.swift
index e78b818..ea8b8a0 100644
--- a/3. Strings and Characters.playground/section-1.swift
+++ b/3. Strings and Characters.playground/section-1.swift
@@ -1,4 +1,5 @@
// ------------------------------------------------------------------------------------------------
+// Checked and updated September 2016
// Things to know:
//
// * Strings are bridged perfectly with NSString class
@@ -40,11 +41,11 @@ func somefunc(a: String)
}
var originalString = "Original"
-somefunc(originalString)
+somefunc(a: originalString)
originalString // not modified
// You can iterate over a string like this:
-for character in originalString
+for character in originalString.characters
{
character
}
@@ -53,18 +54,8 @@ for character in originalString
// instead of a String:
var notAString: Character = "t"
-// There is no length or count member of string, you have to use the global function,
-// countElements()
-//
-// This is much like calling strlen in which it iterates over the Unicode string and counts
-// characters. Note that Unicode chars are different lenghts, so this is a non-trivial process.
-//
-// “Note also that the character count returned by countElements is not always the same as the
-// length property of an NSString that contains the same characters. The length of an NSString is
-// based on the number of 16-bit code units within the string’s UTF-16 representation and not the
-// number of Unicode characters within the string. To reflect this fact, the length property from
-// NSString is called utf16count when it is accessed on a Swift String value.”
-countElements(originalString)
+// Use String.characters.count to get number of characters in a string
+originalString.characters.count
// Strings can be concatenated with strings and characters
var helloworld = "hello, " + "world"
diff --git a/3. Strings and Characters.playground/timeline.xctimeline b/3. Strings and Characters.playground/timeline.xctimeline
index ceeb430..9169aa0 100644
--- a/3. Strings and Characters.playground/timeline.xctimeline
+++ b/3. Strings and Characters.playground/timeline.xctimeline
@@ -3,7 +3,9 @@
version = "3.0">
+ documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=2651&EndingColumnNumber=5&EndingLineNumber=10&StartingColumnNumber=4&StartingLineNumber=10&Timestamp=496705345.61362"
+ selectedRepresentationIndex = "0"
+ shouldTrackSuperviewWidth = "NO">
diff --git a/4a. Arrays.playground/contents.xcplayground b/4a. Arrays.playground/contents.xcplayground
index 18a12f6..8e39341 100644
--- a/4a. Arrays.playground/contents.xcplayground
+++ b/4a. Arrays.playground/contents.xcplayground
@@ -4,4 +4,4 @@
-
+
\ No newline at end of file
diff --git a/4a. Arrays.playground/playground.xcworkspace/contents.xcworkspacedata b/4a. Arrays.playground/playground.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/4a. Arrays.playground/playground.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/4a. Arrays.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate b/4a. Arrays.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..0b729bd
Binary files /dev/null and b/4a. Arrays.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/4a. Arrays.playground/section-1.swift b/4a. Arrays.playground/section-1.swift
index 716b695..4f3a760 100644
--- a/4a. Arrays.playground/section-1.swift
+++ b/4a. Arrays.playground/section-1.swift
@@ -1,4 +1,5 @@
// ------------------------------------------------------------------------------------------------
+// Checked and updated September 2016
// Things to know:
//
// * Arrays are ordered lists of elements
@@ -72,7 +73,7 @@ shoppingList[4...6] = ["Banannas", "Apples"]
shoppingList[4..<6] = ["Limes", "Mint leaves", "Sugar"]
// We can insert an item at a given index
-shoppingList.insert("Maple Syrup", atIndex: 3)
+shoppingList.insert("Maple Syrup", at: 3)
// We can remove the last element. During this, we can preserve the value of what was removed
// into a stored value
@@ -87,9 +88,9 @@ for item in shoppingList
item
}
-// We can also use the the enumerate() method to return a tuple containing the index and value
+// We can also use the the enumerated() method to return a tuple containing the index and value
// for each element:
-for (index, value) in enumerate(shoppingList)
+for (index, value) in shoppingList.enumerated()
{
index
value
@@ -111,11 +112,11 @@ someInts
someInts = []
// We can initialize an array and and fill it with default values
-var threeDoubles = [Double](count: 3, repeatedValue: 3.3)
+var threeDoubles = [Double](repeating: 3.3, count: 3)
// We can also use the Array initializer to fill it with default values. Note that we don't need to
// specify type since it is inferred:
-var anotherThreeDoubles = Array(count: 3, repeatedValue: 2.5)
+var anotherThreeDoubles = Array(repeating: 2.5, count: 3)
// If you store an array in a constant, it is considered "Immutable"
let immutableArray = ["a", "b"]
diff --git a/4a. Arrays.playground/timeline.xctimeline b/4a. Arrays.playground/timeline.xctimeline
index 69032d4..e5cd975 100644
--- a/4a. Arrays.playground/timeline.xctimeline
+++ b/4a. Arrays.playground/timeline.xctimeline
@@ -3,7 +3,9 @@
version = "3.0">
+ documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=5468&EndingColumnNumber=5&EndingLineNumber=18&StartingColumnNumber=4&StartingLineNumber=18&Timestamp=496705559.74359"
+ selectedRepresentationIndex = "0"
+ shouldTrackSuperviewWidth = "NO">
diff --git a/4b. Dictionaries.playground/contents.xcplayground b/4b. Dictionaries.playground/contents.xcplayground
index 18a12f6..8e39341 100644
--- a/4b. Dictionaries.playground/contents.xcplayground
+++ b/4b. Dictionaries.playground/contents.xcplayground
@@ -4,4 +4,4 @@
-
+
\ No newline at end of file
diff --git a/4b. Dictionaries.playground/playground.xcworkspace/contents.xcworkspacedata b/4b. Dictionaries.playground/playground.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/4b. Dictionaries.playground/playground.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/4b. Dictionaries.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate b/4b. Dictionaries.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..6733f84
Binary files /dev/null and b/4b. Dictionaries.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/4b. Dictionaries.playground/section-1.swift b/4b. Dictionaries.playground/section-1.swift
index c901f6c..f395986 100644
--- a/4b. Dictionaries.playground/section-1.swift
+++ b/4b. Dictionaries.playground/section-1.swift
@@ -1,4 +1,5 @@
// ------------------------------------------------------------------------------------------------
+// Checked and updated September 2016
// Things to know:
//
// * Dictionaries store multiple values of the same type, each associated with a key which acts as
@@ -59,7 +60,7 @@ airports["APL"] = nil
// Here's another way to remove a value. The returned value is set to the value that was removed.
// Again, this is optional in case there was no value to remove. In this case, the APL airport
// was already removed, so the return value will be a nil optional:
-var removedValue = airports.removeValueForKey("APL")
+var removedValue = airports.removeValue(forKey: "APL")
// ------------------------------------------------------------------------------------------------
// Iterating over a Dictionary
diff --git a/4b. Dictionaries.playground/timeline.xctimeline b/4b. Dictionaries.playground/timeline.xctimeline
index 372dfbb..2cb8bdf 100644
--- a/4b. Dictionaries.playground/timeline.xctimeline
+++ b/4b. Dictionaries.playground/timeline.xctimeline
@@ -3,10 +3,14 @@
version = "3.0">
+ documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=4862&EndingColumnNumber=5&EndingLineNumber=17&StartingColumnNumber=4&StartingLineNumber=17&Timestamp=496705615.515135"
+ selectedRepresentationIndex = "0"
+ shouldTrackSuperviewWidth = "NO">
+ documentLocation = "#CharacterRangeLen=11&CharacterRangeLoc=3423&EndingColumnNumber=12&EndingLineNumber=78&StartingColumnNumber=1&StartingLineNumber=78&Timestamp=496705615.515477"
+ selectedRepresentationIndex = "0"
+ shouldTrackSuperviewWidth = "NO">
diff --git a/5. Control Flow.playground/contents.xcplayground b/5. Control Flow.playground/contents.xcplayground
index 18a12f6..8e39341 100644
--- a/5. Control Flow.playground/contents.xcplayground
+++ b/5. Control Flow.playground/contents.xcplayground
@@ -4,4 +4,4 @@
-
+
\ No newline at end of file
diff --git a/5. Control Flow.playground/playground.xcworkspace/contents.xcworkspacedata b/5. Control Flow.playground/playground.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/5. Control Flow.playground/playground.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/5. Control Flow.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate b/5. Control Flow.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..75e4066
Binary files /dev/null and b/5. Control Flow.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/5. Control Flow.playground/section-1.swift b/5. Control Flow.playground/section-1.swift
index 75753f2..71a623f 100644
--- a/5. Control Flow.playground/section-1.swift
+++ b/5. Control Flow.playground/section-1.swift
@@ -1,4 +1,5 @@
// ------------------------------------------------------------------------------------------------
+// Checked and updated September 2016
// Things to know:
//
// * Much of the control flow in Swift is similar to C-like languages, but there are some key
@@ -59,7 +60,7 @@ indx
// We can use an underscore if you don't need access to the loop constant:
for _ in 1...10
{
- println("do something")
+ print("do something")
}
// We can iterate over arrays
@@ -78,7 +79,7 @@ for (animalName, legs) in numberOfLegs
}
// We can iterate over characters in a String
-for character in "Hello"
+for character in "Hello".characters
{
character
}
@@ -87,20 +88,20 @@ for character in "Hello"
//
// Note that the loop value is a variable, not a constant. In fact, they cannot be constant
// because of the increment statement (++index)
-for (var index = 0; index < 3; ++index)
+for index in 0 ..< 3
{
index
}
// The parenthesis are optional for the For-Condition-Increment loop:
-for var index = 0; index < 3; ++index
+for index in 0 ..< 3
{
index
}
// Variables are scoped to the For-Condition-Increment construct. To alter this, pre-declare index
var index = 3000
-for index = 0; index < 3; ++index
+for index in 0 ..< 3
{
index
}
@@ -113,15 +114,15 @@ index // Index holds 3 after running through the loop
// through the loop:
while index > 0
{
- --index
+ index -= 1
}
// Do-While loops also resemble their C-like language counterparts. They perform the condition
// after each iteration through the loop. As a result, they always execute the code inside the
// loop at least once:
-do
+repeat
{
- ++index
+ index += 1
} while (index < 3)
// ------------------------------------------------------------------------------------------------
@@ -267,7 +268,7 @@ switch anotherPoint
"On the y axis with an y value of \(y)"
case (var x, let y):
- ++x // We can modify the variable 'x', but not the constant 'y'
+ x += 1 // We can modify the variable 'x', but not the constant 'y'
"Somewhere else on \(x), \(y)"
}
@@ -358,7 +359,7 @@ switch integerToDescribe
var result = ""
nameLoop: for name in names
{
- characterLoop: for character in name
+ characterLoop: for character in name.characters
{
theSwitch: switch character
{
@@ -377,7 +378,7 @@ result
result = ""
nameLoop: for name in names
{
- characterLoop: for character in name
+ characterLoop: for character in name.characters
{
theSwitch: switch character
{
@@ -397,7 +398,7 @@ result
result = ""
nameLoop: for name in names
{
- characterLoop: for character in name
+ characterLoop: for character in name.characters
{
theSwitch: switch character
{
diff --git a/5. Control Flow.playground/timeline.xctimeline b/5. Control Flow.playground/timeline.xctimeline
index c1278f9..7c016be 100644
--- a/5. Control Flow.playground/timeline.xctimeline
+++ b/5. Control Flow.playground/timeline.xctimeline
@@ -3,7 +3,9 @@
version = "3.0">
+ documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=11061&EndingColumnNumber=5&EndingLineNumber=3&StartingColumnNumber=4&StartingLineNumber=3&Timestamp=496706041.965868"
+ selectedRepresentationIndex = "0"
+ shouldTrackSuperviewWidth = "NO">
diff --git a/6. Functions.playground/contents.xcplayground b/6. Functions.playground/contents.xcplayground
index 18a12f6..8e39341 100644
--- a/6. Functions.playground/contents.xcplayground
+++ b/6. Functions.playground/contents.xcplayground
@@ -4,4 +4,4 @@
-
+
\ No newline at end of file
diff --git a/6. Functions.playground/playground.xcworkspace/contents.xcworkspacedata b/6. Functions.playground/playground.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/6. Functions.playground/playground.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/6. Functions.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate b/6. Functions.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..7a57707
Binary files /dev/null and b/6. Functions.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/6. Functions.playground/section-1.swift b/6. Functions.playground/section-1.swift
index b281d2d..3eb6703 100644
--- a/6. Functions.playground/section-1.swift
+++ b/6. Functions.playground/section-1.swift
@@ -1,4 +1,5 @@
// ------------------------------------------------------------------------------------------------
+// Checked and updated September 2016
// Things to know:
//
// * Like most other languages, functions contain units of code to perform a task, but there are
@@ -25,7 +26,7 @@ func sayHello(personName: String) -> String
}
// If we call the function, we'll receive the greeting
-sayHello("Peter Parker")
+sayHello(personName: "Peter Parker")
// Multiple input parameters are separated by a comma
func halfOpenRangeLength(start: Int, end: Int) -> Int
@@ -87,7 +88,7 @@ addSeventeen(toNumber: 42)
//
// The following declaration creates an internal parameter named "action" as well as an external
// parameter named "action":
-func kangaroosCan(#action: String) -> String
+func kangaroosCan(action: String) -> String
{
return "A Kangaroo can \(action)"
}
@@ -108,7 +109,7 @@ func addMul(firstAdder: Int, secondAdder: Int, multiplier: Int = 1) -> Int
}
// We can call with just two parameters to add them together
-addMul(1, 2)
+addMul(firstAdder: 1, secondAdder: 2)
// Default parameter values and external names
//
@@ -119,7 +120,7 @@ addMul(1, 2)
//
// Therefore, when calling the function and specifying a value for the defaulted parameter, we
// must provide the default parameter's external name:
-addMul(1, 2, multiplier: 9)
+addMul(firstAdder: 1, secondAdder: 2, multiplier: 9)
// We can opt out of the automatic external name for default parameter values by specify an
// external name of "_" like so:
@@ -129,10 +130,10 @@ func anotherAddMul(firstAdder: Int, secondAdder: Int, _ multiplier: Int = 1) ->
}
// Here, we call without the third parameter as before:
-anotherAddMul(1, 2)
+anotherAddMul(firstAdder: 1, secondAdder: 2)
// And now we can call with an un-named third parameter:
-anotherAddMul(1, 2, 9)
+anotherAddMul(firstAdder: 1, secondAdder: 2, 9)
// ------------------------------------------------------------------------------------------------
// Variadic Parameters
@@ -158,12 +159,12 @@ func arithmeticMean(numbers: Double...) -> Double
// Let's call it with a few parameter lengths. Note that we can call with no parameters, since that
// meets the criteria of a variadic parameter (zero or more).
arithmeticMean()
-arithmeticMean(1)
-arithmeticMean(1, 2)
-arithmeticMean(1, 2, 3)
-arithmeticMean(1, 2, 3, 4)
-arithmeticMean(1, 2, 3, 4, 5)
-arithmeticMean(1, 2, 3, 4, 5, 6)
+arithmeticMean(numbers: 1)
+arithmeticMean(numbers: 1, 2)
+arithmeticMean(numbers: 1, 2, 3)
+arithmeticMean(numbers: 1, 2, 3, 4)
+arithmeticMean(numbers: 1, 2, 3, 4, 5)
+arithmeticMean(numbers: 1, 2, 3, 4, 5, 6)
// If we want to use variadic parameters and default parameter values, we can do so by making sure
// that the default parameters come before the variadic, at the end of the parameter list:
@@ -185,11 +186,11 @@ anotherArithmeticMean()
// default parameter values. In this case, it helps us recognize where the defalt parameters leave
// off and the variadic parameters begin:
anotherArithmeticMean(initialTotal: 1)
-anotherArithmeticMean(initialTotal: 1, 2)
-anotherArithmeticMean(initialTotal: 1, 2, 3)
-anotherArithmeticMean(initialTotal: 1, 2, 3, 4)
-anotherArithmeticMean(initialTotal: 1, 2, 3, 4, 5)
-anotherArithmeticMean(initialTotal: 1, 2, 3, 4, 5, 6)
+anotherArithmeticMean(initialTotal: 1, numbers: 2)
+anotherArithmeticMean(initialTotal: 1, numbers: 2, 3)
+anotherArithmeticMean(initialTotal: 1, numbers: 2, 3, 4)
+anotherArithmeticMean(initialTotal: 1, numbers: 2, 3, 4, 5)
+anotherArithmeticMean(initialTotal: 1, numbers: 2, 3, 4, 5, 6)
// Variadic parameters with external parameter names only apply their external name to the first
// variadic parameter specified in the function call (if present.)
@@ -217,14 +218,16 @@ yetAnotherArithmeticMean(initialTotal: 1, values: 2, 3, 4, 5, 6)
// Constant and variable parameters
//
// All function parameters are constant by default. To make them variable, add the var introducer:
-func padString(var str: String, pad: Character, count: Int) -> String
+func padString(str: String, pad: Character, count: Int) -> String
{
- str = Array(count: count, repeatedValue: pad) + str
+ var str = str
+ str = String(repeating: String(pad), count: count) + str
+
return str
}
var paddedString = "padded with dots"
-padString(paddedString, ".", 10)
+padString(str: paddedString, pad: ".", count: 10)
// Note that the function does not modify the caller's copy of the string that was passed in
// because the value is still passed by value:
@@ -239,7 +242,7 @@ paddedString
// Note that inout parameters cannot be variadic or have default parameter values.
//
// We'll write a standard swap function to exercise this:
-func swap(inout a: Int, inout b: Int)
+func swap(a: inout Int, b: inout Int)
{
let tmp = a
a = b
@@ -298,10 +301,10 @@ doMul(4, 5)
//
// This additional syntactic decoration has a purpose, but it doesn't affect the underlying
// function type, which remains: (Int, Int) -> Int
-let doAddMul: (a: Int, b: Int, Int) -> Int = addMul
+let doAddMul: (_ a: Int, _ b: Int, Int) -> Int = addMul
// Calling the function now requires external names for the first two parameters
-doAddMul(a: 4, b: 2, 55)
+doAddMul(4, 2, 55)
// We can pass function types as parameters to funcions, too.
//
@@ -314,7 +317,7 @@ func doDoMul(doMulFunc: (Int, Int) -> Int, a: Int, b: Int) -> Int
// We can now pass the function (along with a couple parameters to call it with) to another
// function:
-doDoMul(doMul, 5, 5)
+doDoMul(doMulFunc: doMul, a: 5, b: 5)
// We can also return function types.
//
diff --git a/6. Functions.playground/timeline.xctimeline b/6. Functions.playground/timeline.xctimeline
index d07a687..ede1119 100644
--- a/6. Functions.playground/timeline.xctimeline
+++ b/6. Functions.playground/timeline.xctimeline
@@ -3,7 +3,9 @@
version = "3.0">
+ documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=13442&EndingColumnNumber=5&EndingLineNumber=5&StartingColumnNumber=4&StartingLineNumber=4&Timestamp=496706989.211164"
+ selectedRepresentationIndex = "0"
+ shouldTrackSuperviewWidth = "NO">
diff --git a/7. Closures.playground/contents.xcplayground b/7. Closures.playground/contents.xcplayground
index 18a12f6..8e39341 100644
--- a/7. Closures.playground/contents.xcplayground
+++ b/7. Closures.playground/contents.xcplayground
@@ -4,4 +4,4 @@
-
+
\ No newline at end of file
diff --git a/7. Closures.playground/playground.xcworkspace/contents.xcworkspacedata b/7. Closures.playground/playground.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/7. Closures.playground/playground.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/7. Closures.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate b/7. Closures.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..2d32deb
Binary files /dev/null and b/7. Closures.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/7. Closures.playground/section-1.swift b/7. Closures.playground/section-1.swift
index b46fb84..9d34c06 100644
--- a/7. Closures.playground/section-1.swift
+++ b/7. Closures.playground/section-1.swift
@@ -1,4 +1,5 @@
// ------------------------------------------------------------------------------------------------
+// Checked and updated September 2016
// Things to know:
//
// * Closures are blocks of code.
@@ -34,10 +35,11 @@
// outside of those curly braces:
let names = ["Chris", "Alex", "Ewa", "Barry", "Daniella"]
var reversed = [String]()
-reversed = names.sorted({
- (s1: String, s2: String) -> Bool in
- return s1 > s2
-})
+
+reversed = names.sorted() {
+ (s1: String, s2: String) -> Bool in
+ return s1 > s2
+}
// ------------------------------------------------------------------------------------------------
// Inferring Type from Context
@@ -49,29 +51,29 @@ reversed = names.sorted({
// call to sort.
//
// The following call is identical to the one above with the exception that "-> Bool" was removed:
-reversed = names.sorted({
+reversed = names.sorted() {
(s1: String, s2: String) in
return s1 > s2
-})
+}
// Just as the return type can be inferred, so can the parameter types. This allows us to simplify
// the syntax a bit further by removing the type annotations from the closure's parameters.
//
// The following call is identical to the one above with the exception that the parameter type
// annotations (": String") have been removed:
-reversed = names.sorted({
+reversed = names.sorted() {
(s1, s2) in
return s1 > s2
-})
+}
// Since all types can be inferred and we're not using any type annotation on the parameters,
// we can simplify a bit further by removing the paranthesis around the parameters. We'll also put
// it all on a single line, since it's a bit more clear now:
-reversed = names.sorted({ s1, s2 in return s1 > s2 })
+reversed = names.sorted() { s1, s2 in return s1 > s2 }
// If the closuere has only a single expression, then the return statement is also inferred. When
// this is the case, the closure returns the value of the single expression:
-reversed = names.sorted({ s1, s2 in s1 > s2 })
+reversed = names.sorted() { s1, s2 in s1 > s2 }
// We're not done simplifying yet. It turns out we can get rid of the parameters as well. If we
// remove the parameters, we can still access them because Swift provides shorthand names to
@@ -85,7 +87,7 @@ reversed = names.sorted({ s1, s2 in s1 > s2 })
// This won't compile because you're not allowed to use shorthand names if you specify the
// parameter list. Therefore, we need to remove those in order to get it to compile. This makes
// for a very short inline closure:
-reversed = names.sorted({ $0 > $1 })
+reversed = names.sorted() { $0 > $1 }
// Interestingly enough, the operator < for String types is defined as:
//
@@ -96,12 +98,12 @@ reversed = names.sorted({ $0 > $1 })
// exactly this.
//
// Here's what that looks like:
-reversed = names.sorted(>)
+reversed = names.sorted()
// If you want to just sort a mutable copy of an array (in place) you can use the sort() method
var mutableCopyOfNames = names
-mutableCopyOfNames.sort(>)
+mutableCopyOfNames.sorted(by: >)
mutableCopyOfNames
diff --git a/7. Closures.playground/timeline.xctimeline b/7. Closures.playground/timeline.xctimeline
index 435340c..3f3c9a9 100644
--- a/7. Closures.playground/timeline.xctimeline
+++ b/7. Closures.playground/timeline.xctimeline
@@ -3,7 +3,9 @@
version = "3.0">
+ documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=8015&EndingColumnNumber=5&EndingLineNumber=15&StartingColumnNumber=4&StartingLineNumber=15&Timestamp=496707385.938404"
+ selectedRepresentationIndex = "0"
+ shouldTrackSuperviewWidth = "NO">
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/playground.xcworkspace/contents.xcworkspacedata b/8. Enumerations.playground/playground.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/8. Enumerations.playground/playground.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/8. Enumerations.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate b/8. Enumerations.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..59e5c3c
Binary files /dev/null and b/8. Enumerations.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/8. Enumerations.playground/section-1.swift b/8. Enumerations.playground/section-1.swift
index acf994d..04c71f3 100644
--- a/8. Enumerations.playground/section-1.swift
+++ b/8. Enumerations.playground/section-1.swift
@@ -1,4 +1,5 @@
// ------------------------------------------------------------------------------------------------
+// Checked and updated September 2016
// Things to know:
//
// * Enumerations in Swift are different from their popular counterparts in C-like languages.
@@ -21,32 +22,33 @@
//
// Unlike their C counterparts, the members of the enumeration below are not integer values (0,
// 1, 2, etc.) Instead, each member is a fully-fledged value in its own right.
+// In Swift 3, enums now have members in lowercase
enum Planet
{
- case Mercury
- case Venus
- case Earth
- case Mars
- case Jupiter
- case Saturn
- case Uranus
- case Neptune
+ case mercury
+ case venus
+ case earth
+ case mars
+ case jupiter
+ case saturn
+ case uranus
+ case neptune
}
// You can also combine members onto a single line if you prefer, or mix them up. This has no
// effect on the enumeration itself.
enum CompassPoint
{
- case North, South
- case East, West
+ case north, south
+ case east, west
}
// Let's store an enumeration value into a variable. We'll let the compiler infer the type:
-var directionToHead = CompassPoint.West
+var directionToHead = CompassPoint.west
// Now that directionToHead has a CompassPoint type (which was inferred) we can set it to a
// different CompassPoint value using a shorter syntax:
-directionToHead = .East
+directionToHead = .east
// We can use a switch to match values from an enumeration.
//
@@ -54,13 +56,13 @@ directionToHead = .East
// enumeration only has 4 values, so as long as we cover all 4, we don't need the default case.
switch directionToHead
{
- case .North:
+ case .north:
"North"
- case .South:
+ case .south:
"South"
- case .East:
+ case .east:
"East"
- case .West:
+ case .west:
"West"
}
@@ -150,11 +152,11 @@ FamilyPet.Ferret.rawValue
var pet = FamilyPet(rawValue: "Ferret")
// Let's verify this:
-if pet != .None { "We have a pet!" }
+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")
-if pet != .None { "We have a pet" }
+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..c0fc5c7 100644
--- a/8. Enumerations.playground/timeline.xctimeline
+++ b/8. Enumerations.playground/timeline.xctimeline
@@ -3,7 +3,9 @@
version = "3.0">
+ documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=5615&EndingColumnNumber=5&EndingLineNumber=21&StartingColumnNumber=4&StartingLineNumber=21&Timestamp=496707552.497048"
+ selectedRepresentationIndex = "0"
+ shouldTrackSuperviewWidth = "NO">
diff --git a/9. Classes and Structures.playground/contents.xcplayground b/9. Classes and Structures.playground/contents.xcplayground
index 18a12f6..8e39341 100644
--- a/9. Classes and Structures.playground/contents.xcplayground
+++ b/9. Classes and Structures.playground/contents.xcplayground
@@ -4,4 +4,4 @@
-
+
\ No newline at end of file
diff --git a/9. Classes and Structures.playground/playground.xcworkspace/contents.xcworkspacedata b/9. Classes and Structures.playground/playground.xcworkspace/contents.xcworkspacedata
new file mode 100644
index 0000000..919434a
--- /dev/null
+++ b/9. Classes and Structures.playground/playground.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+
+
+
+
+
diff --git a/9. Classes and Structures.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate b/9. Classes and Structures.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate
new file mode 100644
index 0000000..aa6bd89
Binary files /dev/null and b/9. Classes and Structures.playground/playground.xcworkspace/xcuserdata/christopher.xcuserdatad/UserInterfaceState.xcuserstate differ
diff --git a/9. Classes and Structures.playground/section-1.swift b/9. Classes and Structures.playground/section-1.swift
index 8add319..4ee24a6 100644
--- a/9. Classes and Structures.playground/section-1.swift
+++ b/9. Classes and Structures.playground/section-1.swift
@@ -1,4 +1,5 @@
// ------------------------------------------------------------------------------------------------
+// Checked September 2016
// Things to know:
//
// Classes and structures can both:
diff --git a/9. Classes and Structures.playground/timeline.xctimeline b/9. Classes and Structures.playground/timeline.xctimeline
index d16a576..bd09315 100644
--- a/9. Classes and Structures.playground/timeline.xctimeline
+++ b/9. Classes and Structures.playground/timeline.xctimeline
@@ -3,7 +3,9 @@
version = "3.0">
+ documentLocation = "#CharacterRangeLen=0&CharacterRangeLoc=5589&EndingColumnNumber=5&EndingLineNumber=4&StartingColumnNumber=4&StartingLineNumber=4&Timestamp=496707619.317768"
+ selectedRepresentationIndex = "0"
+ shouldTrackSuperviewWidth = "NO">
diff --git a/README.md b/README.md
index e5ddcf3..aacb091 100644
--- a/README.md
+++ b/README.md
@@ -9,8 +9,7 @@ Learn Apple's Swift programming language interactively through these playgrounds
###What you'll need
- You will need XCode 6.0 GM (or later) or 6.1 Beta 2 (or later) and probably
- a Mac to run it on.
+ You will need XCode 8.0 GM (or later) and a Mac to run it on.
###Purpose & Goal
@@ -39,3 +38,5 @@ Learn Apple's Swift programming language interactively through these playgrounds
Thanks to Rafał Wójcik for his quick work to update these playgrounds to
incorporate the Swift language changes that came with XCode Beta 3.
+
+ Most playgrounds updated to Swift 3 by Christopher Bell.