Table of Contents
Introduction
Who This Book Is For
What This Book Covers
How This Book Is Structured
Instructional Videos
Conventions
Errata
p2p.wrox.com
Section I: Hello iOS!
Lesson 1: Hello iOS!
iOS Developer Essentials
TRY IT
Lesson 2: A Tour of Xcode and the iOS Simulator
The Welcome Screen
Creating a New Project
An Overview of the Xcode IDE
Features of the iOS Simulator
Try It
Lesson 3: Introducing Swift
Introducing Xcode Playgrounds
Constants and Variables
Data Types
Comments
Strings
Tuples
Optionals
Control Flow Statements
Control Transfer Statements
Try It
Lesson 4: Functions
Declaring Functions
Parameters and Return Values
Try It
Lesson 5: Closures
Function Types
Closure Types
Try It
Lesson 6: Error Handling
The ErrorType Protocol
Throwing and Catching Errors
Try It
Lesson 7: Object-Oriented Programming with Swift
Creating Classes with Swift
Properties
Methods
Instantiating Objects
Inheritance
Computed Properties
Enumerations
Protocols
Try It
Lesson 8: Supporting Multiple Device Types
Device Differences
The Universal XCode Template
Try It
Lesson 9: Introduction to UIKit and Adaptive Layout
Introducing the UIKit Framework
Basic Constraints
Previewing Your Layout
Creating Outlets
Creating Actions
Try It
Lesson 10: Introduction to Storyboards
Try It
Section II: More iOS Development
Lesson 11: Handling User Input
Text Fields
Text Views
Try It
Lesson 12: Alert Views and Action Sheets
Alert Views
Action Sheets
Try It
Lesson 13: Adding Images to Your View
The UIImage Class
The UIImageView Class
Try It
Lesson 14: Pickers
Date Pickers
Custom Pickers
Try It
Lesson 15: Navigation Controllers
Adding a Navigation Controller to a Storyboard
The Navigation Controller Interface
Try It
Lesson 16: Table Views
Table View Appearance
Creating a Table View with Interface Builder
Try It
Lesson 17: Collection Views
Creating a Collection View with Interface Builder
Collection View Cells
Collection View Delegate and Data Source
Try It
Lesson 18: Tab Bars and Toolbars
Creating a Tab Bar Controller
Toolbars
Try It
Lesson 19: Creating Views That Scroll
The UIScrollView Class
Scroll Views and Text Fields
Try It
Lesson 20: Popovers and Modal Views
Popovers
Modal Views
Try It
Lesson 21: Touches and Gestures
Touch Events
Gesture Recognizers
Try It
Section III: Storing Data and Network Programming
Lesson 22: Property Lists
Creating Property Lists
Reading Property Lists
Try It
Lesson 23: Application Settings
Adding a Settings Bundle
Reading Preferences with Code
Try It
Lesson 24: Introduction to iCloud Storage
Basic Concepts
Preparing to Use the iCloud Storage APIs
Checking for Service Availability
Using iCloud Document Storage
Try It
Lesson 25: Introduction to CloudKit
Containers, Databases, and Records
Development and Production Environments
The CloudKit Dashboard
Preparing to Use CloudKit
Common Operations
Try It
Lesson 26: Introduction to Core Data
Basic Concepts
Adding Core Data to a Project
Instantiating Core Data Objects
Writing Managed Objects
Reading Managed Objects
Try It
Lesson 27: Consuming RESTful JSON Web Services
Types of Web Services
JSON and NSJSONSerialization
NSURLSession and Application Transport Security
Try It
Section IV: Beyond the Basics
Lesson 28: Social Media Integration
The Share Sheet
Try It
Lesson 29: Where Am I? Introducing Core Location
Permissions
Accuracy
Receiving Location Updates
Handling Errors and Checking Hardware Availability
Geocoding and Reverse Geocoding
Obtaining Compass Headings
Try It
Lesson 30: Introduction to Map Kit
Adding Annotations
Accessory Views
Try It
Lesson 31: Using the Camera and Photo Library
Selecting the Image Source
Presenting the Image Picker
Try It
Lesson 32: Introduction to User Interface Testing
Adding Support for UI Testing to Your Project
Anatomy of a Test Case
New Classes for UI Testing
Test Assertions
UI Recording
Waiting for Elements in a UI Test
Try It
Lesson 33: Introduction to Test Driven Development
Adding Support for Unit Testing to Your Project
TDD Techniques
Anatomy of a Test Case
Test Assertions
Try It
Section V: Reference
Appendix A: Testing Your App on a Device
Obtaining and Registering UDIDs
Creating an App ID (Bundle Identifier)
Creating a Development Certificate
Creating a Provisioning Profile
Configuring Your Project
Appendix B: Beta Testing with TestFlight
Preparing a Distribution Build for TestFlight
Internal and External Testers
Appendix C: App Store Distribution
Creating an Application Profile
Preparing and Uploading the Application Binary
Submitting the App for Review
End User License Agreement
Pages
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
53
54
55
56
57
58
59
60
61
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
85
86
87
88
89
90
91
92
93
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
141
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
203
204
205
206
207
208
209
210
211
212
213
214
215
217
218
219
220
221
222
223
224
225
226
227
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
Guide
Cover
Table of Contents
Begin Reading
List of Illustrations
Lesson 1: Hello iOS!
Figure 1.1
Figure 1.2
Figure 1.3
Figure 1.4
Figure 1.5
Figure 1.6
Figure 1.7
Figure 1.8
Figure 1.9
Figure 1.10
Figure 1.11
Figure 1.12
Lesson 2: A Tour of Xcode and the iOS Simulator
Figure 2.1
Figure 2.2
Figure 2.3
Figure 2.4
Figure 2.5
Figure 2.6
Figure 2.7
Figure 2.8
Figure 2.9
Figure 2.10
Figure 2.11
Figure 2.12
Figure 2.13
Figure 2.14
Figure 2.15
Figure 2.16
Figure 2.17
Figure 2.18
Figure 2.19
Figure 2.20
Figure 2.21
Figure 2.22
Figure 2.23
Lesson 3: Introducing Swift
Figure 3.1
Figure 3.2
Figure 3.3
Lesson 7: Object-Oriented Programming with Swift
Figure 7.1
Figure 7.2
Figure 7.3
Figure 7.4
Lesson 8: Supporting Multiple Device Types
Figure 8.1
Figure 8.2
Figure 8.3
Figure 8.4
Figure 8.5
Lesson 9: Introduction to UIKit and Adaptive Layout
Figure 9.1
Figure 9.2
Figure 9.3
Figure 9.4
Figure 9.5
Figure 9.6
Figure 9.7
Figure 9.8
Figure 9.9
Figure 9.10
Figure 9.11
Figure 9.12
Figure 9.13
Figure 9.14
Figure 9.15
Figure 9.16
Figure 9.17
Figure 9.18
Figure 9.19
Figure 9.20
Figure 9.21
Lesson 10: Introduction to Storyboards
Figure 10.1
Figure 10.2
Figure 10.3
Figure 10.4
Figure 10.5
Figure 10.6
Figure 10.7
Figure 10.8
Figure 10.9
Figure 10.10
Figure 10.11
Figure 10.12
Figure 10.13
Figure 10.14
Figure 10.15
Figure 10.16
Lesson 11: Handling User Input
Figure 11.1
Figure 11.2
Figure 11.3
Figure 11.4
Figure 11.5
Figure 11.6
Figure 11.7
Lesson 12: Alert Views and Action Sheets
Figure 12.1
Figure 12.2
Figure 12.3
Figure 12.4
Figure 12.5
Figure 12.6
Lesson 13: Adding Images to Your View
Figure 13.1
Figure 13.2
Figure 13.3
Figure 13.4
Figure 13.5
Lesson 14: Pickers
Figure 14.1
Figure 14.2
Figure 14.3
Figure 14.4
Figure 14.5
Figure 14.6
Figure 14.7
Figure 14.8
Lesson 15: Navigation Controllers
Figure 15.1
Figure 15.2
Figure 15.3
Figure 15.4
Figure 15.1
Figure 15.6
Figure 15.7
Lesson 16: Table Views
Figure 16.1
Figure 16.2
Figure 16.3
Figure 16.4
Figure 16.5
Figure 16.6
Figure 16.7
Figure 16.8
Figure 16.9
Figure 16.10
Figure 16.11
Lesson 17: Collection Views
Figure 17.1
Figure 17.2
Figure 17.3
Figure 17.4
Figure 17.5
Figure 17.6
Lesson 18: Tab Bars and Toolbars
Figure 18.1
Figure 18.2
Figure 18.3
Figure 18.4
Figure 18.5
Figure 18.6
Figure 18.7
Figure 18.8
Figure 18.9
Figure 18.10
Figure 18.11
Figure 18.12
Figure 18.13
Figure 18.14
Figure 18.15
Figure 18.16
Figure 18.17
Lesson 19: Creating Views That Scroll
Figure 19.1
Figure 19.2
Figure 19.3
Figure 19.4
Figure 19.5
Figure 19.6
Figure 19.7
Figure 19.8
Lesson 20: Popovers and Modal Views
Figure 20.1
Figure 20.2
Figure 20.3
Figure 20.4
Figure 20.5
Figure 20.6
Figure 20.7
Figure 20.8
Lesson 21: Touches and Gestures
Figure 21.1
Figure 21.2
Lesson 22: Property Lists
Figure 22.1
Figure 22.2
Figure 22.3
Figure 22.4
Lesson 23: Application Settings
Figure 23.1
Figure 23.2
Figure 23.3
Figure 23.4
Figure 23.5
Figure 23.6
Figure 23.7
Figure 23.8
Figure 23.9
Lesson 24: Introduction to iCloud Storage
Figure 24.1
Figure 24.2
Figure 24.3
Figure 24.4
Figure 24.5
Figure 24.6
Figure 24.7
Figure 24.8
Figure 24.9
Figure 24.10
Figure 24.11
Figure 24.12
Figure 24.13
Figure 24.14
Figure 24.15
Figure 24.16
Figure 24.17
Lesson 25: Introduction to CloudKit
Figure 25.1
Figure 25.2
Figure 25.3
Figure 25.4
Figure 25.5
Figure 25.6
Figure 25.7
Figure 25.8
Figure 25.9
Figure 25.10
Figure 25.11
Figure 25.12
Figure 25.13
Figure 25.14
Figure 25.15
Figure 25.16
Figure 25.17
Figure 25.18
Figure 25.19
Figure 25.20
Figure 25.21
Figure 25.22
Figure 25.23
Figure 25.24
Figure 25.25
Figure 25.26
Figure 25.27
Figure 25.28
Figure 25.29
Figure 25.30
Figure 25.31
Figure 25.32
Figure 25.33
Figure 25.34
Figure 25.35
Figure 25.36
Figure 25.37
Figure 25.38
Figure 25.39
Figure 25.40
Figure 25.41
Figure 25.42
Lesson 26: Introduction to Core Data
Figure 26.1
Figure 26.2
Figure 26.3
Figure 26.4
Figure 26.5
Figure 26.6
Figure 26.7
Figure 26.8
Figure 26.9
Figure 26.10
Figure 26.11
Lesson 27: Consuming RESTful JSON Web Services
Figure 27.1
Figure 27.2
Figure 27.3
Figure 27.4
Lesson 28: Social Media Integration
Figure 28.1
Figure 28.2
Figure 28.3
Figure 28.4
Lesson 29: Where Am I? Introducing Core Location
Figure 29.1
Figure 29.2
Figure 29.3
Lesson 30: Introduction to Map Kit
Figure 30.1
Figure 30.2
Figure 30.3
Figure 30.4
Figure 30.5
Figure 30.6
Lesson 31: Using the Camera and Photo Library
Figure 31.1
Figure 31.2
Figure 31.3
Lesson 32: Introduction to User Interface Testing
Figure 32.1
Figure 32.2
Figure 32.3
Figure 32.4
Figure 32.5
Figure 32.6
Figure 32.7
Figure 32.8
Figure 32.9
Figure 32.10
Lesson 33: Introduction to Test Driven Development
Figure 33.1
Figure 33.2
Figure 33.3
Figure 33.4
Figure 33.5
Figure 33.6
Figure 33.7
Figure 33.8
Figure 33.9
Figure 33.10
List of Tables
Lesson 1: Hello iOS!
Table 1.1 Home Screen Icon Sizes
Lesson 3: Introducing Swift
Table 3.1 Common Swift Data Types
Lesson 7: Object-Oriented Programming with Swift
Table 7.1 Characteristics of the Automobile Class
Table 7.2 Operations in the Automobile Class
Lesson 8: Supporting Multiple Device Types
Table 8.1 Summary of Screen Sizes
Table 8.2 Icon Sizes
Lesson 9: Introduction to UIKit and Adaptive Layout
Table 9.1 UIButton Touch Events
Table 9.2 UILabel Properties
Lesson 13: Adding Images to Your View
Table 13.1 UIImage Supported File Formats
Lesson 19: Creating Views That Scroll
Table 19.1 Layout Constraints
Lesson 20: Popovers and Modal Views
Table 20.1 Layout Constraints
Lesson 23: Application Settings
Table 23.1 Preference Types
Table 23.2 Layout Constraints
Lesson 25: Introduction to CloudKit
Table 25.1 CloudKit Field Types
Table 25.2 Layout Constraints
Table 25.3 Layout Constraints
Lesson 27: Consuming RESTful JSON Web Services
Table 27.1 MathService Methods
Table 27.2 Mapping Foundation to JSON Types
Table 27.3 Layout Constraints
Lesson 28: Social Media Integration
Table 28.1 Layout Constraints
Lesson 29: Where Am I? Introducing Core Location
Table 29.1 CLLocationManager Service Availability Methods
Table 29.2 Layout Constraints
Lesson 31: Using the Camera and Photo Library
Table 31.1 Layout Constraints
Lesson 32: Introduction to User Interface Testing
Table 32.1 XCUIElementQuery Methods
Table 32.2 XCUIElement Methods
Table 32.3 XCUIElementAttribute Properties
Table 32.4 XCUIElementTypeQueryProvider Methods
Table 32.5 XCTest Assertion Macros
Table 32.6 Layout Constraints
Lesson 33: Introduction to Test Driven Development
Table 33.1 XCTest Assertion Macros
Table 33.2 Layout Constraints
Table 33.3 Test Cases