A B C D E F G H I J-K L M N O P Q R S T U V W X-Y-Z
1> prompt, 8
+ (addition) operator, 29
= (assignment) operator, 14, 30, 44, 246
: (colon), 16
/* ... */ (comment blocks), 7
-= compound assignment operator, 31
*= compound assignment operator, 31
/= compound assignment operator, 31
%= compound assignment operator, 31
+= compound assignment operator, 31
+ (concatenation) operator, 9
{} (curly braces), 109, 279, 302
-- (decrement) operator, 28
/ (division) operator, 29
// (double forward slash), 7
== (equality) operator, 31
! (exclamation point), 208
> (greater than) operator, 31
>= (greater than or equal to) operator, 31
++ (increment) operator, 28
!= (inequality) comparison operator, 31
== (is-equal) operator, 415
< (less than) operator, 31
<= (less than or equal to) operator, 31
&& (logical AND) operator, 33-34
! (logical NOT) operator, 35
|| (logical OR) operator, 34-35
- (minus sign), 379
* (multiplication) operator, 29
?? (nil coalescing) operator, 83
? (optional chaining) operator, 318
() parentheses, 64
+ (plus sign), 379
; (semicolon), 22
- (subtraction) operator, 29
- (unary minus) operator, 29
+ (unary plus) operator, 29
_ (wildcard underscore), 101
Abrahams, Dave, 343
access control
in extensions, 313
internal access, 248
private access, 248
accessing
methods
instance methods on enums, 192
with optional chaining, 322-324
REPL (Read-Eval-Print-Loop), 8
accessors
property accessors
overview, 225
addition-assignment compound operator, 43
addition (+) operator, 29
adoption of protocols
definition of, 279
allocation, Objective-C, 383-384
annotation, 16
appending array elements, 43
append() method, 43
Apple documentation, 417
App Store, downloading Xcode from, 2
arc4random() function, 66
ARC (Automatic Reference Counting), 262
how it works, 265
reference cycles
reference relationships, 265-266
strong references, 265
unowned references, 270-272, 276
area() method, 175
areIntsEqual() function, 329
areStringsEqual() function, 329
areTheseEqual() function, 329-330
arguments, 114
validation, 112
arithmetic operators, 29
arrays, 332
appending elements to, 43
compared to dictionaries, 56
for loops, 96
functions as members of arrays, 133
generic function to return an array, 331
inserting elements into, 43-44
member types, 40
methods, 46
properties, 46
type bridging in Objective-C, 386
zero-based arrays, 41
as! keyword, 291
as? operator, 291
assignment operator, 14, 30, 44
assignment operator (=), 246
Assistant Editor, 6
associated values
bindings, 191
named parameters, 190
Automatic Reference Counting. See ARC (Automatic Reference Counting)
binary operators
assignment operator, 14, 30, 44
combinations of logical operators, 35
compound assignment operators, 30-31
explained, 29
logical NOT operator, 35
standard arithmetic operators, 29
bindings, associated values, 191
BluePotion struct, 294
Book class, 287
Bool data type, 20
Boolean types, 20
Bool type (Objective-C), 399
bridging
definition of term, 384
Array and NSArray, 386
Dictionary and NSDictionary, 387
Numeric Types and NSNumber, 386
String and NSString, 386
bridging header, 384
Bundle Identifier, 4
ButtonDelegate class, 293
ButtonDelegateProtocol, 293
buttonTapped() method, 293
calling
functions, 108
capital letters as generic placeholder types, 136
capture, closure capture lists, 272-275
casting down. See unwrapping optionals
from throwing function, 367-369
trying without catching, 369-371
chaining
chaining functions together
optional chaining
importance of, 325
use cases, 316
when to use, 325
checking for protocol conformance, 291
child classes, 167
Circle class, 156
classes, 148. See also inheritance; methods
Book, 287
ButtonDelegate, 293
child classes, 167
Circle class, 156
comparing to structs, 149-150, 155-156
class instance references, 159-160
instance equality, 160
mutating properties, 158
DetailVC, 392
Document, 320
DVD, 287
GameManager, 296
initialization, 207-209, 262-263
default initializer parameters, 207-208
failable initializers, 208-209
initialization delegation, 211-212
Library, 320
MathFunction, 273
Media, 286
NSError, 364
NSMutableDictionary, 47
NSNumber, 386
NSString, 386
Objective-C classes
exposing to Swift, 394
parent classes, 167
Person, 267
Rectangle, 214
Site, 319
SomeClassWithExpensiveOperation, 223
SomeClassWithLazyVar, 223
subclasses, 167
overriding instance methods, 170-171
superclasses, 167
overriding inherited methods, 169
syntax, 155
TestClass, 263
TheLegendOfZelda, 295
updating in storyboard, 395-396
class keyword, 239
class subscripts, 166
clauses
else
where, 87
closed for modification, 301
closing REPL (Read-Eval-Print-Loop), 9
closure capture lists, 272-275
closures, 134
as parameters, 137
shorthand argument names, 138
single-expression closures, 137
strong reference cycles, 272-275
trailing closures, 139, 142-143
collections
arrays
appending elements to, 43
compared to dictionaries, 56
inserting elements into, 43-44
member types, 40
methods, 46
properties, 46
zero-based arrays, 41
definition of term, 39
dictionaries
compared to arrays, 56
explained, 47
initializing, 48
methods, 50
properties, 50
removing items from, 50
heterogeneous collections, 353-355
homogeneous collections, 353-355
sets
creating, 51
definition of term, 51
performing actions on, 54
retrieving elements from, 52
use case, 56
CollectionType protocol extension, 345
colon (:), 16
combining
logical operators, 35
strings, 9
comments, 7
comparisons
structs and classes, 149-150, 155-156
comparing class instance references, 159-160
instance equality, 160
mutating properties, 158
composition, protocol composition, 289-290
compound assignment operators, 30-31, 43
computed properties, 186, 224-225
computed instance properties, 303-305
computed type properties, 241-242
concatenating strings, 21
concatenation (+) operator, 9
concrete types, converting protocol sequences to, 355-357
conditional checking, validating user input with, 85-86
conditional operators, 35
conditionals
advanced pattern matching, 72-73
C/Objective C versus Swift, 60
ternary conditional operators, 63-64
overview, 59
switch statement
break statement, 71
explicit break, 65
fall through, 65
matching multiple values, 65-66
ternary conditional operators, 63-64
conditions
for-condition-increment loop, 94
while loops, 90
configureView() method, 393, 395
conformance (protocol)
checking for, 291
definition of term, 279
constants, 149
assigning values to, 14
naming, 15
when to use, 14
controlling program flow. See program flow, controlling with conditionals
control of execution, transferring
break statement, 71
convenience initializers, 211
converting
between integers and floating-point numbers, 19
copying value types, 149
Core Data, 302
counts, reference count, 262
count property, 46
Create a New Xcode Project command, 2
creating. See also declaring; initialization
immutable variables, 7
playgrounds, 6
sets, 51
variables, 79
curly braces ({}), 109, 279, 302
custom initializers
adding with extensions, 308-309
structs, 203
customizing error types, 364-365
data source delegates, 292
data types. See types
deallocation, 261
declaring. See also creating; initialization
enums, 185
functions, 111
methods
mutating functions, 283
decrement operator (--), 28
default initializer parameters, 207-208
default initializers, 201
default protocol implementations, overriding, 349-352
default values
default parameter values, 120
default property values, 200
defer keyword, 122
deferring execution, 122-123, 371-374
defining. See declaring
deinitializers, 276
deinitializing classes, 261-265, 276
deinit keyword, 262
delegates
data source delegates, 292
delegate execution, deferring, 372-373
delegation
initialization delegation
definition of term, 209
deleting projects, 8
Dependency Inversion Principle, 292
dequeue function, 335
description() method, 177
designated initializers, 211, 218
DetailVC class, 392
dictionaries
compared to arrays, 56
explained, 47
for-in loops, 100
initializing, 48
methods, 50
properties, 50
removing items from, 50
sorting, 100
division (/) operator, 29
Document class, 320
double forward slash (//), 7
downloading
starter project (Objective-C), 387-389
Xcode, 2
DVD class, 287
dynamic dispatch, 349
Either, 191
elements
array elements
appending, 43
member types, 40
set elements
retrieving, 52
else clause
Emoji, 15
Enemy struct, 294
enqueue function, 335
enumerators. See enums
getting, 186
equality
equality (==) operator, 31
instance equality, 160
equality (==) comparison operator, 31
Equatable protocol, 415
error handling
explained, 361
out of bounds errors, 43
Swift error handling
customizing error types, 364-365
errors. See error handling
ErrorType protocol, 364-365, 375
exclamation point (!), 208
exclusiveOr() method, 54
execution, deferring, 122-123, 371-374
exhaustive, 64
explicitly declaring data types, 24
explicitly unwrapped optionals. See optional values
explicit type bridging, 385
exposing Objective-C classes to Swift, 394
extending
Objective-C classes with Swift, 394-395
extension keyword, 302
extensions, 301
access control in, 313
adding functionality with, 303
computed instance and type properties, 303-305
instance and type methods, 305-306
protocol adoption and conformance, 310-312
advantages of, 313
availability to subclasses, 313
Core Data, 302
Open/Closed Principle, 302
protocol extensions, 280
CollectionType, 345
SequenceType, 405
external parameter names, 118-120
factory methods, 242
failable initializers, 208-209
fall through, 65
FIFO (First-In-First-Out), 334
files
viewing, 6
Objective-C file structure
explained, 378
filtering values
finding
minimum/maximum ranges of integers, 17
properties/methods of data types, 20-21
first-class types, 184
First-In-First-Out (FIFO), 334
first property, 46
on sequences, 411
flattening objects
flatMap on sequences, 411
floating-point numbers, converting, 19
folders, ObjCInteropTests, 399
forced unwrapping, 80
force try statement (try!), 369-371, 375
forEach function, 143, 406-409, 419
for loops, 94
arrays, 96
C, 95
for-condition-increment loops, 94-95
dictionaries, 100
items, 96
ranges, 97
tuples, 101
Swift, 95
funcName, 109
functional programming, 127, 403-404. See also functions
functions, 107. See also methods
arc4random(), 66
areIntsEqual(), 329
areStringsEqual(), 329
calling, 108
chaining functions together, 410-411
declaring, 111
default parameter values, 120
dequeue, 335
dynamic dispatch, 349
enqueue, 335
external parameter names, 118-120
on sequences, 411
generic functions
comparing equality with, 329
generic function to return an array, 331
structure of, 328
higher order functions, 127
closures, 134
instance methods, 135
internal parameter names, 119
length of, 108
median function, rewriting, 139-140
mutating functions, 283
operator functions, 139
overriding, 357
performing as members of arrays, 133
print(), 329
printWeather(), 328
reduce function, 136
return types and
functions with no parameters and no return type, 110
functions with return types, 114-118
returning mean, median, mode, 116-117
static dispatch, 349
structure of, 108
styMap, 345
syntax, 109
unique, 331
GameManager class, 296
GameManagerDelegate protocol, 295
generics
functions
comparing equality with, 329
generic function to return an array, 331
structure of, 328
generic types
mixing with non-generic parameters, 340
multiple generic types, 340
greater than (>) operator, 31
greater than or equal to (>=) operator, 31
guard let syntax, 371
half-closed range operators, 32, 36
handling errors. See error handling
hashable, 47
header files (Objective-C), 378-380
Healable protocol, 294
Heart struct, 294
heterogeneous collections, 353-355
hiding parameter names in initializers, 206-207
higher order functions, 127
closures, 134
homogeneous collections, 353-355
identical to operator, 159
identifying reference cycles, 266-269
C/Objective C versus Swift, 60
ternary conditional operators, 63-64
ignoring return values, 118
@implementation keyword, 381
implementation files (Objective-C), 380-382
implicitly unwrapped optionals, 81-82
implicit returns, 137
import Cocoa statement, 6
import UIKit statement, 6
increment operator (++), 28
inequality (!=) comparison operator, 31
inference, type inference, 15-16
inferred type bridging, 385
infinite loops, 91
infix operators, 29
inheritance
base classes, 166
protocols, 298
single inheritance, 172
initialization
default initializer parameters, 207-208
fallable initializers, 208-209
definition of term, 199
dictionaries, 48
initialization delegation
definition of term, 209
initialization process, 212-217
adding with extensions, 308-309
convenience initializers, 211
default initializers, 201, 207-208
designated initializers, 211, 218
hiding parameter names in, 206-207
inheritance, 218
inherited initializers, 211
properties in structs, 151
safety, 212
external parameter names in initializers, 206-207
setting default values, 202-206
adding with extensions, 308-309
convenience initializers, 211
default initializers, 201, 207-208
designated initializers, 211, 218
hiding parameter names in, 206-207
inheritance, 218
inherited initializers, 211
init() method, 48, 81, 210. See also initialization
in keyword, 135
inserting
insert() method, 44
instance methods, 135
adding
instance properties
accessing type properties from, 240-241
compared to type properties, 258
instances
instancetype keyword, 380
instance variables, 222
Int data type. See integers
converting between integers and floating-point numbers, 19
extending to adopt and conform to a protocol, 311-312
finding minimum/maximum ranges of, 17
unsigned integers, 17
when to use, 18
integrating Swift into Objective-C
creating Swift class and bridging header, 389-393
downloading starter project, 387-389
exposing Objective-C classes to Swift, 394
extending Objective-C classes with Swift, 394-395
housecleaning, 394
updating classes in storyboard, 395-396
internal access, 248
internal keyword, 248
internal parameter names, 119
intersect, 53
introducers
introspection, 255
iOS playgrounds, 6
isa pointers, 176
isDisjointWith() method, 54
is-equal operator (==), 415
isSubsetOf() method, 53
isSupersetOf() method, 53
iteration
forEach function, 406-409, 419
@interface statement (Objective-C), 378
JSON (JavaScript Object Notation), 257
keywords
as!, 291
Bool, 20
class, 239
deinit, 262
extension, 302
guard, 371
C/Objective C versus Swift, 60
ternary conditional operators, 63-64
@implementation, 381
import, 6
in, 135
instancetype, 380
@interface, 378
internal, 248
lazy, 223
nesting, 74
nil, 77
objc, 298
optional, 290
private, 248
protocol, 279
public, 248
rethrows, 345
strong, 379
switch
break statement, 71
explicit break, 65
fall through, 65
matching multiple values, 65-66
UInt, 17
weak, 269
last property, 46
lazy keyword, 223
lazy stored properties, 223-224, 236
leaks, memory, 276
length of functions, 108
less than (<) operator, 31, 415
less than or equal to (<=) operator, 31
Library class, 320
Liskov Substitution Principle, 357
lists
closure capture lists, 272-275
tasks list, removing items from, 45
literals, 19
logical operators
combining, 35
explained, 33
logical NOT, 35
loops
for loops, 94
for-condition-increment loops, 94-95
infinite loops, 91
transferring control
break statement, 103
conditions, 90
Mac playgrounds, 6
manipulating arrays
adding elements to, 43
inserting elements into, 43-44
mapEachElement, 134
matching
advanced pattern matching, 72-73
MathFunction class, 273
Mavericks, Xcode compatibility, 11
maximum ranges of integers, finding, 17
mean, functions returning, 116-117
Media class, 286
median, functions returning, 116-117
median function
playgrounds, 142
MelonType enum, 204
memberwise initialization, 151, 155, 202-203
memory
deallocating, 261
memory leaks, 276
pointers, 22
memory leaks, 276
methods, 148. See also functions
adding with extensions, 305-306
append(), 43
area(), 175
arrays, 46
buttonTapped(), 293
deinit, 262
description(), 177
dictionaries, 50
exclusiveOr(), 54
factory methods, 242
init(), 48, 81, 210. See also initialization
in protocols
default implementation, 298
insert(), 44
isDisjointWith(), 54
isSubsetOf(), 53
isSupersetOf(), 53
nested method calls, 383
nullable method parameters, 383
numberOfSectionsInTableView, 358
prepareForSegue:sender:, 393
reduce instance, 136
removeAll(), 45
removeAtIndex(), 45
removeLast(), 45
removeValueForKey(), 50
self.init(), 211
subscript, 251
super.init(), 218
toInt(), 23
turnItDown(), 245
typeMethodName(), 242
Meyer, Bertrand, 302
Microsoft SharePoint Server, 318
minimum ranges of integers, finding, 17
MKAnnotation protocol, 290
mode, functions returning, 116-117
modifiers, @objc, 290
module bridging (Objective-C), 384-385
Mountain Lion, Xcode compatibility, 11
multiple bindings, validating user input with, 85-86
multiple optionals, unwrapping, 83-84
multiple protocols
multiplication (*) operator, 29
mutability, 22
mutating functions, 283
mutating keyword, 158, 283, 305
named parameters, 190
naming conventions, 150
constants, 15
external parameter names in initializers, 206-207
parameters, 236
shorthand argument names, 138
variables, 15
Xcode projects, 4
nesting
method calls, 383
statements, 74
nil coalescing operator, 83
nil keyword, 77
nil values
Objective-C
nullable method parameters, 383
nullable property definitions, 382
None, 192
NSDictionary class, 47, 79, 387
NSError class, 364
NSHipster, 417
NSMutableDictionary class, 47
NSNumber class, 386
NSString class, 386
nullability
nil values
Objective-C
nullable method parameters, 383
nullable property definitions, 382
_Nullable attribute, 383
null_resettable attribute, 382
_Null_unspecified attribute, 383
numberOfSectionsInTableView method, 358
numeric types, 386
@objc modifier, 290
ObjCInteropTests folder, 399
objc keyword, 298
Objective-C
bridging
definition of term, 384
classes
exposing to Swift, 394
compared to Swift, 22
file structure
explained, 378
in-out parameters, 121
integrating Swift into
creating Swift class and bridging header, 389-393
downloading starter project, 387-389
exposing Objective-C classes to Swift, 394
extending Objective-C classes with Swift, 394-395
housecleaning, 394
updating classes in storyboard, 395-396
nested method calls, 383
nullability
nullable method parameters, 383
nullable property definitions, 382
overview, 377
objects
flattening
flatMap function on optionals, 412-414
flatMap on sequences, 411
SharePoint Object Model, 318
observers (property)
Open/Closed Principle, 302
open for extension, 301
operands, 29
operator functions, 139
operators
as?, 291
binary operators
assignment operator, 14, 30, 44
combinations of logical operators, 35
compound assignment operators, 30-31
explained, 29
logical NOT operator, 35
standard arithmetic operators, 29
+ (concatenation), 9
identical to operator, 159
infix operators, 29
optional chaining operator (?), 318
overloading, 414
overview, 27
ternary conditional operators, 35, 63-64
unary operators
decrement operator (--), 28
explained, 27
increment operator (++), 28
logical NOT operator, 28
unary minus operator, 29
unary plus operator, 29
Optical protocol, 286
optional chaining
importance of, 325
use cases, 316
when to use, 325
optional chaining operator (?), 318
optional keyword, 290
optionals. See optional values
optional try statement (try?), 370-371, 375
optional values, 28
additional reading, 84
designating variables as, 78-79
wrapping/unwrapping, 23
forced unwrapping, 80
implicitly unwrapped optionals, 81-82
nil coalescing operator, 83
unwrap operator, 80
order of initialization (Objective-C), 382
Organization Identifier, 4
OS X support for Xcode, 11
out of bounds errors, 43
overloading
operators, 414
override keyword, 169, 253, 282
overrides, 168
default protocol implementations, 349-352
functions, 357
preventing overrides, 231
subscripts, 253
Paper struct, 250
parameters
closures, 137
default initializer parameters, 207-208
default parameter values, 120
external parameter names, 118-120, 206-207
function parameters, 111-112, 132-134
internal parameter names, 119
named parameters, 190
naming, 236
parent classes, 167
parentheses, 64
pattern matching. See matching
Person class, 267
creating, 6
Mac versus iOS playgrounds, 6
median function, 142
pointers, 22
postfix unary operators, 27, 36
prefix unary operators, 27, 36
prepareForSegue:sender: method, 393
preventing overrides, 174-176, 231
printWeather() function, 328
private access, 248
private interfaces, 378
private keyword, 248
ProcessDelegate protocol, 372
program flow, controlling with conditionals
advanced pattern matching, 72-73
C/Objective C versus Swift, 60
ternary conditional operators, 63-64
overview, 59
switch statement
break statement, 71
explicit break, 65
fall through, 65
matching multiple values, 65-66
ternary conditional operators, 63-64
projects
naming, 4
removing, 8
accessors
overview, 225
arrays, 46
computed properties, 186, 224-225, 303-305
dictionaries, 50
initializing in structs, 151
nullable property definitions (Objective-C), 382
property observers
protocol properties
stored properties
definition of term, 221
instance variables, 222
lazy stored properties, 223-224, 236
type properties
compared to instance properties, 258
computed type properties, 241-242
protocol keyword, 279
protocols
adoption
adding with extensions, 310-312
definition of term, 279
advantages of, 298
ButtonDelegateProtocol, 293
converting protocol sequences, 355-357
Equatable, 415
explained, 343
extensions, 280
GameManagerDelegate, 295
Healable, 294
heterogeneous collections, 353-355
homogeneous collections, 353-355
implementing, 344
inheritance, 298
methods
default implementation, 298
MKAnnotation, 290
multiple protocols
naming conventions, 284-285, 347
Optical, 286
overloading operators with, 415-416
overriding default protocol implementations, 349-352
ProcessDelegate, 372
properties
protocol conformance, 279, 291
protocol extensions
CollectionType, 345
Rentable
STYCustomStringConvertible, 395
public interface files (Objective-C), 378
public keyword, 248
Pythagorean Theorem, 151
Queue struct
random number generators, 93
ranges
for-in loop, 97
raw values
getting, 186
initializer, 187
Ray, John, 6
Read-Eval-Print-Loop (REPL), 8-10
Rectangle class, 214
reduce function, 136
reduce instance method, 136
reference cycles
ARC (Automatic Reference Counting), 262
how it works, 265
identifying reference cycles, 266-269
reference relationships, 265-266
resolving reference cycles, 269-272
strong references, 265
unowned references, 270-272, 276
deallocating, 261
reference count, 262
reference cycles
versus values, 131
relationships, reference, 265-266
removeAll() method, 45
removeAtIndex() method, 45
removeLast() method, 45
removeValueForKey() method, 50
removing
tasks list items, 45
Xcode projects, 8
Rentable protocol
replacing array elements, 44-45
REPL (Read-Eval-Print-Loop), 8-10
resolving reference cycles, 269-272
retain count, 262
rethrows keyword, 345
retrieving set elements, 52
returning functions
higher order functions, 128-130
syntax for, 130
return someValue, 109
return statement, 115
return values, ignoring, 118
rewriting median function, 139-140
safety, 212
Sams Teach Yourself iOS Application Development in 24 Hours (Ray), 6
scope, 111
self.init() method, 211
self keyword, 153, 203, 211, 242, 357
semicolon (;), 22
sequences
flattening, 411
protocol sequences, converting, 355-357
SequenceType extension, 405
servers, SharePoint Server, 318
sets
creating, 51
definition of term, 51
performing actions on, 54
retrieving elements from, 52
use case, 56
SharePoint Object Model, 318
SharePoint Server, 318
shorthand syntax
argument names, 138
single-expression closures, 137
single inheritance, 172
Site class, 319
SOLID software development principles, 357
Some, 192
SomeClassWithExpensiveOperation class, 223
SomeClassWithLazyVar class, 223
Song class, 395
sorting dictionaries, 100
standard arithmetic operators, 29
starter project (Objective-C), downloading, 387-389
statements. See also keywords
C/Objective C versus Swift, 60
ternary conditional operators, 63-64
import Cocoa, 6
import UIKit, 6
@interface, 378
nesting, 74
switch
break statement, 71
explicit break, 65
fall through, 65
matching multiple values, 65-66
static dispatch, 349
stored properties
definition of term, 221
instance variables, 222
lazy stored properties, 223-224, 236
storyboard, updating classes in, 395-396
combining, 9
concatenating, 21
extending
with computed properties, 304
mutability, 22
type bridging in Objective-C, 386
String type. See strings
strong keyword, 379
strongly typed languages, 256
strong reference cycles, 261, 265
BluePotion, 294
comparing to classes, 149-150, 155-156
class instance references, 159-160
instance equality, 160
mutating properties, 158
deinitializers and, 276
Enemy, 294
Heart, 294
custom initializers, 203
initialization delegation, 210-211
memberwise initialization, 202-203
memberwise initialization, 155
Paper, 250
Queue
syntax, 155
Volume, 244
STYCustomStringConvertible protocol, 395
styMap function, 345
subclasses, 167
overriding instance methods, 170-171
subscript method, 251
subscripts, 166
adding with extensions, 306-307
overriding, 253
subtraction (-) operator, 29
superclasses, 167
overriding, 169
super.init() method, 218
The Swift Programming Language, 212
switching enum values, 190-192
break statement, 71
explicit break, 65
fall through, 65
matching multiple values, 65-66
tasks list, removing items from, 45
ternary conditional operators, 35, 63-64
TestClass, 263
TheLegendOfZelda class, 295
thread safe, 160
throwing functions, catching errors from, 367-369
toInt() method, 23
tools, xcrun, 8
trailing closures, 139, 142-143
transferring
control of execution
break statement, 71
control of loops
with break statement, 103
with continue statements, 102-103
for-in loops, 101
turnItDown() method, 245
typealias keyword, 246-247, 304, 337
type casting
determining an instance’s type, 253-255
introspection, 255
type inference, 15-16, 48-49, 97, 137
typeMethodName() method, 242
types, 13, 16. See also extensions
annotation, 16
arrays, 332
appending elements to, 43
compared to dictionaries, 56
for loops, 96
functions as members of arrays, 133
generic function to return an array, 331
inserting elements into, 43-44
member types, 40
methods, 46
properties, 46
type bridging in Objective-C, 386
zero-based arrays, 41
declaring explicitly, 24
Dictionary, 332
finding properties/methods of, 20-21
generic types
mixing with non-generic parameters, 340
multiple generic types, 340
initialization, 201
convenience initializers, 211
default initializers, 201
definition of term, 199
designated initializers, 211
inherited initializers, 211
initialization delegation, 209-212
initialization process, 212-217
safety, 212
converting between integers and floating-point numbers, 19
extending to adopt and conform to a protocol, 311-312
finding minimum/maximum ranges of, 17
unsigned integers, 17
when to use, 18
methods
adding with extensions, 305-306
protocol names as types, 284-285
properties
adding with extensions, 303-305
compared to instance properties, 258
computed type properties, 241-242
combining, 9
concatenating, 21
mutability, 22
type bridging in Objective-C, 386
struct
custom initializers, 203
delegation initialization, 210-211
memberwise initialization, 202-203
type bridging
Array and NSArray, 386
Dictionary and NSDictionary, 387
Numeric Types and NSNumber, 386
String and NSString, 386
type casting
definition of term, 253
determining an instance’s type, 253-255
introspection, 255
UI development, 178
UInt data type, 17
unary minus operator, 29
unary operators
decrement operator (--), 28
explained, 27
increment operator (++), 28
logical NOT operator, 28
unary minus operator, 29
unary plus operator, 29
unary plus operator, 29
unions, 53
unique function, 331
unowned references, 270-272, 276
unsigned integers, 17
unwrapping optionals, 23
forced unwrapping, 80
implicitly unwrapped optionals, 81-82
nil coalescing operator, 83
unwrap operator, 80
updating
classes in storyboard, 395-396
use cases
optional chaining, 316
sets, 56
validation
value validation, 112
values
binding, 68
constants
assigning values to, 14
naming, 15
when to use, 14
copying, 149
default property value, 200
enumerations, 47
explained, 78
initialization, 22-23, 41, 201
external parameter names in initializers, 206-207
setting default values, 202-206
literals, 19
nil values
optional values, 28
additional reading, 84
designating variables as, 78-79
wrapping/unwrapping, 23, 79-82
struct, 20
value binding, 68
versus references, 131
value types, 148
value validation, 112
variables
creating, 79
designating as optionals, 78-79
instance variables, 222
naming, 15
optionals
additional reading, 84
wrapping/unwrapping, 23, 79-84
verifying protocol conformance, 291
viewDidLoad() method, 174, 393
Volume struct, 244
weak keyword, 269
websites
Apple documentation, 417
NSHipster, 417
Welcome to Xcode screen, 3
where keyword, 69-70, 87, 352-353
conditions, 90
willSet keyword, 228, 233, 236
wrappers, 78
Xcode
Auto Complete, 394
downloading, 2
projects
naming, 4
removing, 8
raw value initializer, 187
xcrun, 8
Yosemite, support for Xcode, 11
zero-based arrays, 41