Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

?

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

Understanding Your Toddler iOSConf 2016 Daniel H Steinberg @dimsumthinking

Slide 8

Slide 8 text

Understanding Your Toddler iOSConf 2016 Daniel H Steinberg @dimsumthinking

Slide 9

Slide 9 text

Understanding Your Toddler iOSConf 2016 Daniel H Steinberg @dimsumthinking No, this is not the same talk I gave last week at UIKonf

Slide 10

Slide 10 text

Summer 2010

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

Summer 2010

Slide 14

Slide 14 text

Xcode 4 shipped

Slide 15

Slide 15 text

Xcode IB

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

18 months

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

Xcode 4.2

Slide 20

Slide 20 text

LLVM Only

Slide 21

Slide 21 text

iOS 5

Slide 22

Slide 22 text

ARC

Slide 23

Slide 23 text

WWDC 2014

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

Swift 1.0

Slide 26

Slide 26 text

Swift 1.1

Slide 27

Slide 27 text

Swift 1.2

Slide 28

Slide 28 text

WWDC 2015

Slide 29

Slide 29 text

"Swift will be open sourced by the end of this year"

Slide 30

Slide 30 text

December 3, 2015

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

Proposals from the Community

Slide 34

Slide 34 text

PRs from the Community

Slide 35

Slide 35 text

Committers

Slide 36

Slide 36 text

Conversation

Slide 37

Slide 37 text

Swift Evolution

Slide 38

Slide 38 text

Open

Slide 39

Slide 39 text

Swift 3

Slide 40

Slide 40 text

"We have had a focus on getting to source stability"

Slide 41

Slide 41 text

Swift 3 focus on source stability

Slide 42

Slide 42 text

API design guidelines Focus and refine the language Adoption of naming guidelines in key APIs Automatic application of naming guidelines to imported Objective-C APIs Swiftification of imported Objective-C APIs Improvements to tooling quality

Slide 43

Slide 43 text

API design guidelines Focus and refine the language Adoption of naming guidelines in key APIs Automatic application of naming guidelines to imported Objective-C APIs Swiftification of imported Objective-C APIs Improvements to tooling quality

Slide 44

Slide 44 text

API design guidelines Focus and refine the language Adoption of naming guidelines in key APIs Automatic application of naming guidelines to imported Objective-C APIs Swiftification of imported Objective-C APIs Improvements to tooling quality

Slide 45

Slide 45 text

API design guidelines Focus and refine the language Adoption of naming guidelines in key APIs Automatic application of naming guidelines to imported Objective-C APIs Swiftification of imported Objective-C APIs Improvements to tooling quality

Slide 46

Slide 46 text

API design guidelines Focus and refine the language Adoption of naming guidelines in key APIs Automatic application of naming guidelines to imported Objective-C APIs Swiftification of imported Objective-C APIs Improvements to tooling quality

Slide 47

Slide 47 text

API design guidelines Focus and refine the language Adoption of naming guidelines in key APIs Automatic application of naming guidelines to imported Objective-C APIs Swiftification of imported Objective-C APIs Improvements to tooling quality

Slide 48

Slide 48 text

Swift 3 focus on source stability

Slide 49

Slide 49 text

A Few Previews of Coming Attractions

Slide 50

Slide 50 text

0025 - Scoped Access Levels

Slide 51

Slide 51 text

public internal private

Slide 52

Slide 52 text

public internal private

Slide 53

Slide 53 text

public internal private

Slide 54

Slide 54 text

public internal private

Slide 55

Slide 55 text

public internal fileprivate

Slide 56

Slide 56 text

public internal fileprivate private

Slide 57

Slide 57 text

class MyClass { private var myProperty = "Hello" private func myPrivateMethod() { print(myProperty) } fileprivate func myFilePrivateMethod(numberOfTimes times: Int) { for _ in 1 ... times { myPrivateMethod() } } } extension MyClass { func myExtensionMethod(numberOfTimes times: Int) { myFilePrivateMethod(numberOfTimes: times) } }

Slide 58

Slide 58 text

class MyClass { private var myProperty = "Hello" private func myPrivateMethod() { print(myProperty) } fileprivate func myFilePrivateMethod(numberOfTimes times: Int) { for _ in 1 ... times { myPrivateMethod() } } } extension MyClass { func myExtensionMethod(numberOfTimes times: Int) { myFilePrivateMethod(numberOfTimes: times) } }

Slide 59

Slide 59 text

class MyClass { private var myProperty = "Hello" private func myPrivateMethod() { print(myProperty) } fileprivate func myFilePrivateMethod(numberOfTimes times: Int) { for _ in 1 ... times { myPrivateMethod() } } } extension MyClass { func myExtensionMethod(numberOfTimes times: Int) { myFilePrivateMethod(numberOfTimes: times) } }

Slide 60

Slide 60 text

class MyClass { private var myProperty = "Hello" private func myPrivateMethod() { print(myProperty) } fileprivate func myFilePrivateMethod(numberOfTimes times: Int) { for _ in 1 ... times { myPrivateMethod() } } } extension MyClass { func myExtensionMethod(numberOfTimes times: Int) { myFilePrivateMethod(numberOfTimes: times) } }

Slide 61

Slide 61 text

class MyClass { private var myProperty = "Hello" private func myPrivateMethod() { print(myProperty) } fileprivate func myFilePrivateMethod(numberOfTimes times: Int) { for _ in 1 ... times { myPrivateMethod() } } } extension MyClass { func myExtensionMethod(numberOfTimes times: Int) { myFilePrivateMethod(numberOfTimes: times) } }

Slide 62

Slide 62 text

public internal fileprivate private

Slide 63

Slide 63 text

0004 - Remove ++ and —

Slide 64

Slide 64 text

while count < upperLimit { print( myArray[count++]) }

Slide 65

Slide 65 text

while count < upperLimit { print( myArray[count++]) }

Slide 66

Slide 66 text

while count < upperLimit { print( myArray[count]) count += 1 }

Slide 67

Slide 67 text

0007 - Remove C Style for loops with conditions and incrementors

Slide 68

Slide 68 text

for (int i = 0; i < array.count; i++)

Slide 69

Slide 69 text

for (int i = 0; i < array.count; i++)

Slide 70

Slide 70 text

0053 - Remove explicit use of let from Function Parameters

Slide 71

Slide 71 text

func double(input: Int) -> Int { // ... }

Slide 72

Slide 72 text

func double(let input: Int) -> Int { // ... }

Slide 73

Slide 73 text

func double(let input: Int) -> Int { // ... }

Slide 74

Slide 74 text

0003 - Remove var from Function Parameters

Slide 75

Slide 75 text

func double(input: Int) -> Int { input = input * 2 return input }

Slide 76

Slide 76 text

func double(var input: Int) -> Int { input = input * 2 return input }

Slide 77

Slide 77 text

func double(var input: Int) -> Int { input = input * 2 return input }

Slide 78

Slide 78 text

func double(input: Int) -> Int { var localInput = input localInput = localInput * 2 return localInput }

Slide 79

Slide 79 text

func double(input: Int) -> Int { var localInput = input localInput = localInput * 2 return localInput }

Slide 80

Slide 80 text

func double(input: Int) -> Int { var input = input input = input * 2 return input } Name Shadowing

Slide 81

Slide 81 text

func double(input: Int) -> Int { var input = input input = input * 2 return input }

Slide 82

Slide 82 text

0031 - Adjusting inout Declarations for Type Decoration

Slide 83

Slide 83 text

func double(input: Int) { input = input * 2 }

Slide 84

Slide 84 text

func double(inout input: Int) { input = input * 2 }

Slide 85

Slide 85 text

func double(inout input: Int) { input = input * 2 }

Slide 86

Slide 86 text

func double(input: inout Int) { input = input * 2 }

Slide 87

Slide 87 text

0053 - Limiting inout capture to @noescape context

Slide 88

Slide 88 text

func escape(f: () -> ()) {} func example(inout x: Int) { escape { _ = x } }

Slide 89

Slide 89 text

func escape(f: () -> ()) {} func example(inout x: Int) { escape { _ = x } }

Slide 90

Slide 90 text

func escape(f: () -> ()) {} func example(inout x: Int) { escape { _ = x } }

Slide 91

Slide 91 text

func escape(f: () -> ()) {} func example(inout x: Int) { escape { _ = x } }

Slide 92

Slide 92 text

func escape(f: () -> ()) {} func example(inout x: Int) { escape { _ = x } }

Slide 93

Slide 93 text

func escape(f: () -> ()) {} func example(inout x: Int) { escape { _ = x } }

Slide 94

Slide 94 text

func escape(f: () -> ()) {} func example(inout x: Int) { escape { _ = x } }

Slide 95

Slide 95 text

func noEscape(@noescape f: () -> ()) {} func example(inout x: Int) { noEscape { _ = x } }

Slide 96

Slide 96 text

func noEscape(@noescape f: () -> ()) {} func example(inout x: Int) { noEscape { _ = x } } safe because @noescape => closure can't be called after function returns

Slide 97

Slide 97 text

func escape(f: () -> ()) {} func example(inout x: Int) { escape { _ = x } }

Slide 98

Slide 98 text

func escape(f: () -> ()) {} func example(inout x: Int) { escape {[x] in _ = x } }

Slide 99

Slide 99 text

func escape(f: () -> ()) {} func example(inout x: Int) { escape {[x] in _ = x } } [x] is a capture list a constant is initialized to have the value of x

Slide 100

Slide 100 text

0049 - Move @noescape and @autoclosure to be type attributes

Slide 101

Slide 101 text

func noEscape(@noescape f: () -> ()) {}

Slide 102

Slide 102 text

func noEscape(f: @noescape () -> ()) {}

Slide 103

Slide 103 text

func noEscape(f: @autoclosure () -> ()) {}

Slide 104

Slide 104 text

0002 - Remove currying func declaration syntax

Slide 105

Slide 105 text

0002 - Remove currying func declaration syntax

Slide 106

Slide 106 text

0002 - Remove currying func declaration syntax

Slide 107

Slide 107 text

func curried(x: Int)(y: Int) -> Int { return {(y: Int) -> Int in return x * y } } curried(7)(8)

Slide 108

Slide 108 text

func curried(x: Int)(y: Int) -> Int { return {(y: Int) -> Int in return x * y } } curried(7)(8)

Slide 109

Slide 109 text

func curried(x: Int)(y: Int) -> Int { return {(y: Int) -> Int in return x * y } } curried(7)(8)

Slide 110

Slide 110 text

func curried(x: Int)(y: Int) -> Int { return {(y: Int) -> Int in return x * y } } curried(7)(8)

Slide 111

Slide 111 text

func curried(x: Int)(y: Int) -> Int { return {(y: Int) -> Int in return x * y } } curried(7)(8) 7 * y

Slide 112

Slide 112 text

func curried(x: Int)(y: Int) -> Int { return {(y: Int) -> Int in return x * y } } curried(7)(8) 7 * 8

Slide 113

Slide 113 text

func curried(x: Int)(y: Int) -> Int { return {(y: Int) -> Int in return x * y } } curried(7)(8)

Slide 114

Slide 114 text

func curried(x: Int)(y: Int) -> Int { return {(y: Int) -> Int in return x * y } } curried(7)(8)

Slide 115

Slide 115 text

func curried(x: Int)(y: Int) -> Int { return {(y: Int) -> Int in return x * y } } curried(7)(8)

Slide 116

Slide 116 text

func curried(x: Int) -> (y: Int) -> Int { return {(y: Int) -> Int in return x * y } } curried(7)(8)

Slide 117

Slide 117 text

func curried(x: Int) -> (y: Int) -> Int { return {(y: Int) -> Int in return x * y } } curried(7)(8)

Slide 118

Slide 118 text

func curried(x: Int) -> (y: Int) -> Int { return {(y: Int) -> Int in return x * y } } curried(7)(8)

Slide 119

Slide 119 text

func curried(x: Int) -> (y: Int) -> Int { return {(y: Int) -> Int in return x * y } } curried(7)(8)

Slide 120

Slide 120 text

func curried(x: Int) -> (y: Int) -> Int { return {(y: Int) -> Int in return x * y } } curried(7)(8)

Slide 121

Slide 121 text

Testing

Slide 122

Slide 122 text

Playgrounds

Slide 123

Slide 123 text

Package Manager

Slide 124

Slide 124 text

Objective-C

Slide 125

Slide 125 text

0022 - Referencing the Obj-C selector of a method

Slide 126

Slide 126 text

class MyClass : NSObject { func callbackMethod(with notification: NSNotification){} func setNotification() { let center = NSNotificationCenter.defaultCenter() center .addObserver(self, selector: "callbackMethod", name: NSApplicationWillResignActiveNotification, object: NSApplication.sharedApplication()) } }

Slide 127

Slide 127 text

class MyClass : NSObject { func callbackMethod(with notification: NSNotification){} func setNotification() { let center = NSNotificationCenter.defaultCenter() center .addObserver(self, selector: "callbackMethod", name: NSApplicationWillResignActiveNotification, object: NSApplication.sharedApplication()) } }

Slide 128

Slide 128 text

class MyClass : NSObject { func callbackMethod(with notification: NSNotification){} func setNotification() { let center = NSNotificationCenter.defaultCenter() center .addObserver(self, selector: "callbackMethod", name: NSApplicationWillResignActiveNotification, object: NSApplication.sharedApplication()) } }

Slide 129

Slide 129 text

class MyClass : NSObject { func callbackMethod(with notification: NSNotification){} func setNotification() { let center = NSNotificationCenter.defaultCenter() center .addObserver(self, selector: "callbackMethod", name: NSApplicationWillResignActiveNotification, object: NSApplication.sharedApplication()) } }

Slide 130

Slide 130 text

class MyClass : NSObject { func callbackMethod(with notification: NSNotification){} func setNotification() { let center = NSNotificationCenter.defaultCenter() center .addObserver(self, selector: "callbackMethod", name: NSApplicationWillResignActiveNotification, object: NSApplication.sharedApplication()) } }

Slide 131

Slide 131 text

class MyClass : NSObject { func callbackMethod(with notification: NSNotification){} func setNotification() { let center = NSNotificationCenter.defaultCenter() center .addObserver(self, selector: "callbackMethod", name: NSApplicationWillResignActiveNotification, object: NSApplication.sharedApplication()) } }

Slide 132

Slide 132 text

class MyClass : NSObject { func callbackMethod(with notification: NSNotification){} func setNotification() { let center = NSNotificationCenter.defaultCenter() center .addObserver(self, selector: #selector(callbackMethod), name: NSApplicationWillResignActiveNotification, object: NSApplication.sharedApplication()) } }

Slide 133

Slide 133 text

class MyClass : NSObject { func callbackMethod(with notification: NSNotification){} func setNotification() { let center = NSNotificationCenter.defaultCenter() center .addObserver(self, selector: #selector(MyClass.callbackMethod), name: NSApplicationWillResignActiveNotification, object: NSApplication.sharedApplication()) } }

Slide 134

Slide 134 text

class MyClass : NSObject { func callbackMethod(){} func callbackMethod(with notification: NSNotification){} func setNotification() { let center = NSNotificationCenter.defaultCenter() center .addObserver(self, selector: #selector(MyClass.callbackMethod), name: NSApplicationWillResignActiveNotification, object: NSApplication.sharedApplication()) } }

Slide 135

Slide 135 text

class MyClass : NSObject { func callbackMethod(){} func callbackMethod(with notification: NSNotification){} func setNotification() { let center = NSNotificationCenter.defaultCenter() center .addObserver(self, selector: #selector(MyClass.callbackMethod), name: NSApplicationWillResignActiveNotification, object: NSApplication.sharedApplication()) } }

Slide 136

Slide 136 text

class MyClass : NSObject { func callbackMethod(){} func callbackMethod(with notification: NSNotification){} func setNotification() { let center = NSNotificationCenter.defaultCenter() center .addObserver(self, selector: #selector(MyClass.callbackMethod(with:)), name: NSApplicationWillResignActiveNotification, object: NSApplication.sharedApplication()) } }

Slide 137

Slide 137 text

0033 - Import Obj-C constants as Swift types

Slide 138

Slide 138 text

HK_EXTERN NSString * const HKQuantityTypeIdentifierBodyMassIndex; HK_EXTERN NSString * const HKQuantityTypeIdentifierBodyFatPercentage; HK_EXTERN NSString * const HKQuantityTypeIdentifierHeight; HK_EXTERN NSString * const HKQuantityTypeIdentifierBodyMass; HK_EXTERN NSString * const HKQuantityTypeIdentifierLeanBodyMass;

Slide 139

Slide 139 text

HK_EXTERN NSString * const HKQuantityTypeIdentifierBodyMassIndex; HK_EXTERN NSString * const HKQuantityTypeIdentifierBodyFatPercentage; HK_EXTERN NSString * const HKQuantityTypeIdentifierHeight; HK_EXTERN NSString * const HKQuantityTypeIdentifierBodyMass; HK_EXTERN NSString * const HKQuantityTypeIdentifierLeanBodyMass;

Slide 140

Slide 140 text

enum HKQuantityTypeIdentifier : String { case BodyMassIndex case BodyFatPercentage case Height case BodyMass case LeanBodyMass }

Slide 141

Slide 141 text

enum HKQuantityTypeIdentifier : String { case BodyMassIndex case BodyFatPercentage case Height case BodyMass case LeanBodyMass }

Slide 142

Slide 142 text

HK_EXTERN NSString * const HKQuantityTypeIdentifierBodyMassIndex; HK_EXTERN NSString * const HKQuantityTypeIdentifierBodyFatPercentage; HK_EXTERN NSString * const HKQuantityTypeIdentifierHeight; HK_EXTERN NSString * const HKQuantityTypeIdentifierBodyMass; HK_EXTERN NSString * const HKQuantityTypeIdentifierLeanBodyMass;

Slide 143

Slide 143 text

enum HKQuantityTypeIdentifier : String { case BodyMassIndex case BodyFatPercentage case Height case BodyMass case LeanBodyMass }

Slide 144

Slide 144 text

enum HKQuantityTypeIdentifier : String { case BodyMassIndex case BodyFatPercentage case Height case BodyMass case LeanBodyMass }

Slide 145

Slide 145 text

0005 - Better translation of Obj-C APIs into Swift

Slide 146

Slide 146 text

let color = NSColor.blueColor()

Slide 147

Slide 147 text

let color = NSColor.blueColor()

Slide 148

Slide 148 text

let color = NSColor.blueColor() Prune redundant type names

Slide 149

Slide 149 text

let color = NSColor.blue()

Slide 150

Slide 150 text

rootViewController .presentViewController(alert, animated: true, completion: nil)

Slide 151

Slide 151 text

rootViewController .presentViewController(alert, animated: true, completion: nil) Add default arguments

Slide 152

Slide 152 text

rootViewController .presentViewController(alert, animated: true, completion: nil) Nullable trailing closures default = nil

Slide 153

Slide 153 text

rootViewController .presentViewController(alert, animated: true)

Slide 154

Slide 154 text

rootViewController .presentViewController(alert, animated: true) Shouldn't animated default = true

Slide 155

Slide 155 text

rootViewController.presentViewController(alert)

Slide 156

Slide 156 text

rootViewController.presentViewController(alert) Prune redundant type names

Slide 157

Slide 157 text

rootViewController.present(alert)

Slide 158

Slide 158 text

var empty: Bool

Slide 159

Slide 159 text

var empty: Bool Prepend "is" to Bools

Slide 160

Slide 160 text

var isEmpty: Bool

Slide 161

Slide 161 text

addLineToPoint(myPoint)

Slide 162

Slide 162 text

addLineToPoint(myPoint) func addLineToPoint(_: CGPoint)

Slide 163

Slide 163 text

addLineToPoint(myPoint) func addLineToPoint(_: CGPoint) Add first argument labels

Slide 164

Slide 164 text

addLineToPoint(myPoint) func addLineToPoint(_: CGPoint) Add first argument labels

Slide 165

Slide 165 text

addLine(to: myPoint) func addLine(to point: CGPoint) Add first argument labels

Slide 166

Slide 166 text

addLine(to: myPoint) func addLine(to point: CGPoint) Add first argument labels

Slide 167

Slide 167 text

Add first argument labels

Slide 168

Slide 168 text

Add first argument labels

Slide 169

Slide 169 text

var URLHandler

Slide 170

Slide 170 text

var URLHandler Lower case imported types

Slide 171

Slide 171 text

var urlHandler Lower case imported types

Slide 172

Slide 172 text

enum Currency { case Dollars case Euros case Pounds case Yen } Lower case imported types

Slide 173

Slide 173 text

enum Currency { case Dollars case Euros case Pounds case Yen } Lower case imported types

Slide 174

Slide 174 text

enum Currency { case dollars case euros case pounds case yen } Lower case imported types

Slide 175

Slide 175 text

0036 - Requiring Leading Dot Prefixes for Enum Instance Member Implementations

Slide 176

Slide 176 text

enum Currency { case dollars case euros case pounds case yen var symbol: String { switch self { case dollars: return "$" default: return "I don't know" } } }

Slide 177

Slide 177 text

enum Currency { case dollars case euros case pounds case yen var symbol: String { switch self { case .dollars: return "$" default: return "I don't know" } } }

Slide 178

Slide 178 text

enum Currency { case dollars case euros case pounds case yen var symbol: String { switch self { case dollars: return "$" default: return "I don't know" } } }

Slide 179

Slide 179 text

enum Currency { case dollars case euros case pounds case yen var symbol: String { switch self { case .dollars: return "$" default: return "I don't know" } } }

Slide 180

Slide 180 text

enum Currency { case dollars case euros case pounds case yen var symbol: String { switch self { case .dollars: return "$" default: return "I don't know" } } }

Slide 181

Slide 181 text

0043 - Declare variables in 'case' labels with multiple patterns

Slide 182

Slide 182 text

enum MyEnum { case case1(Int,Float) case case2(Float,Int) } switch value { case let .case1(x, 2), let .case2(2, x): print(x) case .case1, .case2: break }

Slide 183

Slide 183 text

enum MyEnum { case case1(Int,Float) case case2(Float,Int) } switch value { case let .case1(x, 2), let .case2(2, x): print(x) case .case1, .case2: break }

Slide 184

Slide 184 text

enum MyEnum { case case1(Int,Float) case case2(Float,Int) } switch value { case let .case1(x, 2), let .case2(2, x): print(x) case .case1, .case2: break }

Slide 185

Slide 185 text

enum MyEnum { case case1(Int,Float) case case2(Float,Int) } switch value { case let .case1(x, 2), let .case2(2, x): print(x) case .case1, .case2: break }

Slide 186

Slide 186 text

enum MyEnum { case case1(Int,Float) case case2(Float,Int) } switch value { case let .case1(x, 2), let .case2(2, x): print(x) case .case1, .case2: break }

Slide 187

Slide 187 text

enum MyEnum { case case1(Int,Float) case case2(Float,Int) } switch value { case let .case1(x, 2), let .case2(2, x): print(x) case .case1, .case2: break }

Slide 188

Slide 188 text

enum MyEnum { case case1(Int,Float) case case2(Float,Int) } switch value { case let .case1(x, 2), let .case2(2, x): print(x) case .case1, .case2: break }

Slide 189

Slide 189 text

0001 - Allow (most) keywords as argument labels

Slide 190

Slide 190 text

calculateRevenue(for sales: Int, in currency: Currency)

Slide 191

Slide 191 text

calculateRevenue(for sales: Int, in currency: Currency)

Slide 192

Slide 192 text

calculateRevenue(for numberOfCopies, in .dollars)

Slide 193

Slide 193 text

0009 - Require self for accessing instance members

Slide 194

Slide 194 text

struct Friend { let name: String let location: String func nameBadge() { print("I'm", name, "from", location) } }

Slide 195

Slide 195 text

struct Friend { let name: String let location: String func nameBadge() { print("I'm", name, "from", location) } }

Slide 196

Slide 196 text

struct Friend { let name: String let location: String func nameBadge() { print("I'm", name, "from", location) } }

Slide 197

Slide 197 text

struct Friend { let name: String let location: String func nameBadge() { print("I'm", self.name, "from", self.location) } }

Slide 198

Slide 198 text

struct Friend { let name: String let location: String func nameBadge() { print("I'm", self.name, "from", self.location) } } Require self for accessing instance members REJECTED

Slide 199

Slide 199 text

0011 - Replace typealias keyword with associatedtype for associated type declarations

Slide 200

Slide 200 text

0011 - Replace typealias keyword with associatedtype for associated type declarations

Slide 201

Slide 201 text

protocol Prot { typealias Container : SequenceType } extension Prot { typealias Element = Container.Generator.Element }

Slide 202

Slide 202 text

protocol Prot { typealias Container : SequenceType } extension Prot { typealias Element = Container.Generator.Element }

Slide 203

Slide 203 text

protocol Prot { associatedtype Container : SequenceType } extension Prot { typealias Element = Container.Generator.Element }

Slide 204

Slide 204 text

0092 Typealiases in protocols and protocol extensions

Slide 205

Slide 205 text

protocol Sequence { associatedtype Iterator : IteratorProtocol typealias Element = Iterator.Element }

Slide 206

Slide 206 text

protocol Sequence { associatedtype Iterator : IteratorProtocol typealias Element = Iterator.Element }

Slide 207

Slide 207 text

func sum(sequence: T) -> Int { return sequence.reduce(0, combine: +) }

Slide 208

Slide 208 text

extension Sequence { typealias Element = Iterator.Element func concat(other: Self) -> [Element] { return Array(self) + Array(other) } }

Slide 209

Slide 209 text

extension Sequence { typealias Element = Iterator.Element func concat(other: Self) -> [Element] { return Array(self) + Array(other) } }

Slide 210

Slide 210 text

0048 Generic Type Aliases

Slide 211

Slide 211 text

typealias StringDictionary = Dictionary typealias DictionaryOfStrings = Dictionary typealias IntFunction = (T) -> Int typealias Vec3 = (T, T, T) typealias BackwardTriple = (T3, T2, T1)

Slide 212

Slide 212 text

typealias StringDictionary = Dictionary typealias DictionaryOfStrings = Dictionary typealias IntFunction = (T) -> Int typealias Vec3 = (T, T, T) typealias BackwardTriple = (T3, T2, T1)

Slide 213

Slide 213 text

typealias StringDictionary = Dictionary typealias DictionaryOfStrings = Dictionary typealias IntFunction = (T) -> Int typealias Vec3 = (T, T, T) typealias BackwardTriple = (T3, T2, T1)

Slide 214

Slide 214 text

typealias StringDictionary = Dictionary typealias DictionaryOfStrings = Dictionary typealias IntFunction = (T) -> Int typealias Vec3 = (T, T, T) typealias BackwardTriple = (T3, T2, T1)

Slide 215

Slide 215 text

typealias StringDictionary = Dictionary typealias DictionaryOfStrings = Dictionary typealias IntFunction = (T) -> Int typealias Vec3 = (T, T, T) typealias BackwardTriple = (T3, T2, T1)

Slide 216

Slide 216 text

0046 Establish consistent label behavior across all parameters including first labels

Slide 217

Slide 217 text

func increase(ourNumber: Int, delta: Int) -> Int { } increase(6, delta: 3)

Slide 218

Slide 218 text

func increase(ourNumber: Int, delta: Int) -> Int { } increase(6, delta: 3)

Slide 219

Slide 219 text

func increase(ourNumber: Int, delta: Int) -> Int { } increase(6, delta: 3)

Slide 220

Slide 220 text

func increase(ourNumber: Int, delta: Int) -> Int { } increase(6, delta: 3)

Slide 221

Slide 221 text

func increase(ourNumber: Int, delta: Int) -> Int { } increase(ourNumber: 6, delta: 3)

Slide 222

Slide 222 text

func increase(_ ourNumber: Int, delta: Int) -> Int { } increase(6, delta: 3)

Slide 223

Slide 223 text

0023 - Swift API Guidelines

Slide 224

Slide 224 text

Swift API Design Guidelines

Slide 225

Slide 225 text

myArray.sort()

Slide 226

Slide 226 text

sort() sorted()

Slide 227

Slide 227 text

sortInPlace() sort()

Slide 228

Slide 228 text

sort() sorted()

Slide 229

Slide 229 text

sort() sorted() Name functions and methods according to their side-effects

Slide 230

Slide 230 text

x.distance(to: y) i.successor() Those without side-effects should read as noun phrases

Slide 231

Slide 231 text

x.sort() x.append(y) Those with side-effects should read as imperative noun phrases

Slide 232

Slide 232 text

sort() sorted()/sorting() Use the “ed/ing” rule to name the nonmutating counterpart of a mutating method

Slide 233

Slide 233 text

Prefer methods to free functions

Slide 234

Slide 234 text

Prefer methods to free functions Protocol Extensions in Swift 2

Slide 235

Slide 235 text

Prefer methods to free functions Protocol Extensions in Swift 2 Except …

Slide 236

Slide 236 text

min(x, y, z) When there's no obvious self

Slide 237

Slide 237 text

print(x) When the function is an unconstrained generic

Slide 238

Slide 238 text

sin(x) When the function is part of the established domain notation

Slide 239

Slide 239 text

Methods can share a base name

Slide 240

Slide 240 text

Methods can share a base name Good when they do analogous things

Slide 241

Slide 241 text

Methods can share a base name Not good (tableView!) when they don't

Slide 242

Slide 242 text

Choose good parameter names

Slide 243

Slide 243 text

func move(from startingIndex: Int, to endingIndex: Int) Choose good parameter names

Slide 244

Slide 244 text

Take advantage of default values

Slide 245

Slide 245 text

Take advantage of default values func hello(name: String = "World")

Slide 246

Slide 246 text

Take advantage of default values init(name: String, hometown: String? = nil)

Slide 247

Slide 247 text

Prefer to locate parameters with defaults at the end init(name: String, hometown: String? = nil)

Slide 248

Slide 248 text

External Argument Labels func move(from startingIndex: Int, to endingIndex: Int)

Slide 249

Slide 249 text

move(from: here to: there)

Slide 250

Slide 250 text

Argument Labels Exceptions

Slide 251

Slide 251 text

min(number1, number2) Omit labels when arguments can't be distinguished

Slide 252

Slide 252 text

Double(someInt) Omit labels in full width inits

Slide 253

Slide 253 text

Double(_ anInt: someInt) Omit labels in full width inits

Slide 254

Slide 254 text

func move(from startingIndex: Int, to endingIndex: Int) When the preposition applies to the whole

Slide 255

Slide 255 text

func moveTo(x: Int, y: Int) When the preposition applies to the whole

Slide 256

Slide 256 text

x.removeBoxes(having Length: 12) When the preposition applies to the whole

Slide 257

Slide 257 text

Swift 3 focus on source stability

Slide 258

Slide 258 text

No content

Slide 259

Slide 259 text

No content

Slide 260

Slide 260 text

Next finish Generics stable ABI

Slide 261

Slide 261 text

No content

Slide 262

Slide 262 text

No content

Slide 263

Slide 263 text

No content

Slide 264

Slide 264 text

No content

Slide 265

Slide 265 text

Understanding Your Toddler iOSConf 2016 Daniel H Steinberg @dimsumthinking