Preface |
|
xv | |
Acknowledgments |
|
xvii | |
About This Book |
|
xviii | |
Part 1 Your Very First App |
|
1 | (78) |
|
|
3 | (11) |
|
1.1 The big picture: iPhone and iPad development |
|
|
4 | (2) |
|
|
4 | (1) |
|
Am I developing or programming? |
|
|
4 | (1) |
|
|
5 | (1) |
|
|
6 | (1) |
|
1.2 Learning what you need to remember |
|
|
6 | (3) |
|
Understanding and remembering key concepts |
|
|
7 | (1) |
|
|
7 | (1) |
|
The importance of pseudocode |
|
|
8 | (1) |
|
1.3 What you need to create apps for iPhones and iPads |
|
|
9 | (4) |
|
You're going to need a Mac |
|
|
9 | (2) |
|
Xcode: the iPhone and iPad development environment |
|
|
11 | (1) |
|
|
12 | (1) |
|
|
13 | (1) |
|
2 Building your first app |
|
|
14 | (9) |
|
2.1 Launching Xcode for the first time |
|
|
15 | (7) |
|
|
15 | (1) |
|
Step 2: Create a new project |
|
|
16 | (1) |
|
Step 3: Set up your project options |
|
|
16 | (2) |
|
Step 4: Run the blank app |
|
|
18 | (1) |
|
Step 5: Add the Hello World text |
|
|
19 | (2) |
|
|
21 | (1) |
|
Step 7: Pat yourself on the back (and review) |
|
|
21 | (1) |
|
|
22 | (1) |
|
3 Your first app, explained |
|
|
23 | (7) |
|
3.1 Xcode templates, explained |
|
|
23 | (1) |
|
3.2 Understanding the single-view application |
|
|
24 | (1) |
|
|
25 | (2) |
|
3.4 The Simulator, defined |
|
|
27 | (2) |
|
Running Hello World in the Simulator |
|
|
28 | (1) |
|
|
29 | (1) |
|
4 Learning more about your development tools: Xcode |
|
|
30 | (9) |
|
4.1 Xcode panels explained |
|
|
31 | (5) |
|
|
32 | (1) |
|
|
33 | (1) |
|
|
34 | (1) |
|
|
35 | (1) |
|
4.2 Xcode icons explained |
|
|
36 | (1) |
|
|
37 | (1) |
|
|
38 | (1) |
|
5 Capturing users' actions: adding buttons |
|
|
39 | (14) |
|
5.1 Adding a label and a button |
|
|
40 | (8) |
|
Step 1: Start a new project using the Single View Application template |
|
|
40 | (1) |
|
Step 2: Add a button and label to the storyboard, and run the app to test it |
|
|
40 | (2) |
|
Step 3: Connect the button and the label to the code (wire them up), and run the app to test it |
|
|
42 | (4) |
|
Step 4: Add code to change the text on the Label when the button is clicked, and run the app to test it |
|
|
46 | (2) |
|
5.2 Changing how the label appears |
|
|
48 | (3) |
|
Step 5: Change how the label looks, and run the app to test it |
|
|
49 | (2) |
|
|
51 | (2) |
|
6 The button app, explained |
|
|
53 | (9) |
|
6.1 The button, explained |
|
|
53 | (4) |
|
Creating outlets (or "How do I contact Butch?") |
|
|
54 | (1) |
|
|
55 | (1) |
|
|
55 | (1) |
|
User interfaces and the front end of apps |
|
|
56 | (1) |
|
|
57 | (2) |
|
6.3 Commenting: you can never be too wordy, can you? |
|
|
59 | (1) |
|
Comments are your friends |
|
|
59 | (1) |
|
|
59 | (1) |
|
|
60 | (2) |
|
7 Capturing user input: adding text boxes |
|
|
62 | (7) |
|
|
63 | (5) |
|
Step 1: Create a new single-view application |
|
|
63 | (1) |
|
Step 2: Add a button and a label to the view |
|
|
63 | (1) |
|
Step 3: Add a text field to the view |
|
|
64 | (1) |
|
Step 4: Connect the button, label, and text box to the code (wire them up), and test the app |
|
|
64 | (2) |
|
Step 5: Add code to change the label, and test the app |
|
|
66 | (2) |
|
|
68 | (1) |
|
|
68 | (1) |
|
8 Playing on the playground |
|
|
69 | (10) |
|
8.1 Swift Playgrounds: learning to interact with others |
|
|
69 | (2) |
|
|
71 | (1) |
|
|
72 | (5) |
|
|
73 | (2) |
|
|
75 | (1) |
|
Double, double, toil and trouble |
|
|
76 | (1) |
|
|
77 | (2) |
Part 2 The Keys To The City: Understanding Key Development Concepts |
|
79 | (88) |
|
9 Go with the flow, man! Controlling the flow of your app |
|
|
81 | (10) |
|
|
81 | (1) |
|
9.2 If you do that again, I'm going to... |
|
|
82 | (2) |
|
9.3 If you do that OR if you... then I'm going to... |
|
|
84 | (1) |
|
9.4 If you do that AND you do this, I |
|
|
85 | (1) |
|
9.5 If you do this, else if you do this, else if you do this... |
|
|
86 | (3) |
|
Printing a line with values of variables and strings |
|
|
87 | (2) |
|
9.6 If you do that, otherwise... |
|
|
89 | (1) |
|
|
90 | (1) |
|
10 While you're doing that... |
|
|
91 | (13) |
|
10.1 Using the while statement to control your code |
|
|
91 | (3) |
|
The while statement in action |
|
|
92 | (2) |
|
Wrapping up the while statement discussion |
|
|
94 | (1) |
|
10.2 Turn around now switch (remember Will Smith?)-the switch statement |
|
|
94 | (2) |
|
|
95 | (1) |
|
10.3 How many fingers am I holding up? |
|
|
96 | (7) |
|
Step 1: Add all the components to the storyboard |
|
|
97 | (1) |
|
Step 2: Make the storyboard connections |
|
|
97 | (1) |
|
Step 3: Create a variable to capture the number guessed: numberGuessed |
|
|
98 | (1) |
|
Step 4: Change the numberGuess variable when the stepper is tapped |
|
|
99 | (1) |
|
Connecting the Guess! button |
|
|
100 | (3) |
|
|
103 | (1) |
|
|
104 | (13) |
|
11.1 Quantum arrays: not really, but that sounds scary, right? |
|
|
104 | (3) |
|
11.2 The for statement and loop |
|
|
107 | (1) |
|
|
107 | (3) |
|
11.4 Creating a state name lookup app |
|
|
110 | (6) |
|
Step 1: Create an app named StateAbbreviationLookup |
|
|
111 | (1) |
|
Step 2: Add the UI components to the storyboard |
|
|
111 | (1) |
|
Step 3: Connect the UI components to the code |
|
|
111 | (1) |
|
Step 4: Create the dictionary of state abbreviations and names |
|
|
112 | (1) |
|
Step 5: Create the code to look up the state abbreviation when the user types in the state name |
|
|
113 | (3) |
|
|
116 | (1) |
|
12 Telling stories with storyboards |
|
|
117 | (8) |
|
|
117 | (1) |
|
12.2 Creating an example storyboard app |
|
|
118 | (4) |
|
Step 1: Create a new app called StoryboardExample |
|
|
118 | (1) |
|
Step 2: Add a second scene to the app |
|
|
118 | (2) |
|
Step 3: Add a navigation bar to the second scene |
|
|
120 | (2) |
|
Step 4: Link the Cancel button to the first scene |
|
|
122 | (1) |
|
12.3 Segue animation types |
|
|
122 | (2) |
|
|
124 | (1) |
|
13 ViewControllers in depth |
|
|
125 | (11) |
|
|
125 | (3) |
|
13.2 The override keyword |
|
|
128 | (1) |
|
13.3 ViewController lifecycles |
|
|
129 | (2) |
|
|
131 | (4) |
|
Step 1: Create a new project called Lifecycle |
|
|
131 | (1) |
|
Step 2: Add a second ViewController |
|
|
131 | (1) |
|
Step 3: Create an unwind segue |
|
|
132 | (1) |
|
Step 4: Override the five functions |
|
|
133 | (1) |
|
|
133 | (2) |
|
|
135 | (1) |
|
14 Put it on my tab: creating tab bars |
|
|
136 | (8) |
|
14.1 The Tab Bar Controller |
|
|
136 | (7) |
|
|
137 | (1) |
|
Step 2: Delete the existing scene |
|
|
137 | (1) |
|
Step 3: Add a Tab Bar Controller to the storyboard |
|
|
138 | (1) |
|
Step 4: Add labels to the different tabs |
|
|
139 | (3) |
|
Step 5: Add a third tab to the app |
|
|
142 | (1) |
|
|
143 | (1) |
|
15 Table views: more than a coffee table picture book |
|
|
144 | (15) |
|
|
145 | (1) |
|
Making pizza from scratch |
|
|
145 | (1) |
|
|
145 | (1) |
|
|
146 | (1) |
|
|
146 | (1) |
|
15.4 Creating a table view app |
|
|
147 | (11) |
|
|
147 | (1) |
|
Step 2: Add a table view to the ViewController |
|
|
147 | (2) |
|
Step 3: Set up a prototype cell |
|
|
149 | (1) |
|
Step 4: Set the protocols for UITableView |
|
|
149 | (5) |
|
Step 5: Create a data source for the pizza |
|
|
154 | (2) |
|
Step 6: Connect the data to a table |
|
|
156 | (2) |
|
|
158 | (1) |
|
16 Patterns: learning to sew |
|
|
159 | (8) |
|
16.1 Design patterns, defined |
|
|
160 | (2) |
|
|
160 | (1) |
|
|
160 | (1) |
|
|
161 | (1) |
|
|
161 | (1) |
|
16.2 Types of design patterns |
|
|
162 | (4) |
|
Model-View-Controller design pattern |
|
|
162 | (2) |
|
|
164 | (1) |
|
|
165 | (1) |
|
|
166 | (1) |
Part 3 Creating The Like It Or Not App |
|
167 | (130) |
|
17 Putting it all together: the LioN app |
|
|
169 | (11) |
|
|
169 | (1) |
|
|
170 | (9) |
|
|
171 | (1) |
|
Adding a Navigation Controller |
|
|
172 | (1) |
|
Adding an iPhone 4s Simulator |
|
|
173 | (2) |
|
Connecting the data to the table view |
|
|
175 | (1) |
|
Implement the functions for table views |
|
|
176 | (3) |
|
|
179 | (1) |
|
18 Adding data to your LioN app |
|
|
180 | (10) |
|
18.1 Adding hardcoded data to your LioN |
|
|
181 | (1) |
|
Creating an array of dummy data |
|
|
181 | (1) |
|
Wiring lionData to the table view with hardcoded data |
|
|
181 | (1) |
|
18.2 Adding a model to the mix |
|
|
182 | (5) |
|
Adding a new Swift file to the project |
|
|
183 | (4) |
|
18.3 Changing the layout of the table cell |
|
|
187 | (2) |
|
Changing the cell in the storyboard to show the description |
|
|
187 | (2) |
|
Updating the function to show the description |
|
|
189 | (1) |
|
|
189 | (1) |
|
19 Displaying details of your LioN |
|
|
190 | (11) |
|
19.1 Capturing the tapped row index |
|
|
190 | (1) |
|
19.2 Adding a detail page to the storyboard |
|
|
191 | (4) |
|
Adding a ViewController to the storyboard |
|
|
192 | (1) |
|
Creating a new ViewController class |
|
|
193 | (2) |
|
19.3 Passing data to the DetailViewController |
|
|
195 | (5) |
|
Preparing the DetailViewController to accept the LioN |
|
|
195 | (1) |
|
Updating the MainViewController to pass data |
|
|
196 | (4) |
|
|
200 | (1) |
|
20 Creating the details of the detail view |
|
|
201 | (11) |
|
20.1 Adding some labels to your detail screen |
|
|
201 | (3) |
|
Converting an Int to a string using the description |
|
|
202 | (1) |
|
Converting an Int to a string using String |
|
|
202 | (2) |
|
20.2 Adding new LioNs to the list |
|
|
204 | (7) |
|
Adding the + button to the view |
|
|
204 | (2) |
|
Creating a function to handle the action and link the two together |
|
|
206 | (1) |
|
Adding hardcoded values to the LioN list |
|
|
207 | (3) |
|
Deleting LioNs from the list |
|
|
210 | (1) |
|
|
211 | (1) |
|
|
212 | (13) |
|
21.1 Creating a new detail view |
|
|
212 | (5) |
|
Adding a new Table ViewController |
|
|
213 | (1) |
|
Adding a new AddEditViewController class |
|
|
214 | (2) |
|
Hooking up the Cancel and Done buttons |
|
|
216 | (1) |
|
|
216 | (1) |
|
|
217 | (6) |
|
Don't allow the cell to be selected |
|
|
219 | (1) |
|
Setting the keyboard behaviors |
|
|
220 | (2) |
|
Dismissing the keyboard on user tap |
|
|
222 | (1) |
|
|
223 | (2) |
|
22 Delegates are everywhere |
|
|
225 | (11) |
|
22.1 Connecting your views |
|
|
225 | (4) |
|
Implementing the protocol |
|
|
227 | (1) |
|
Updating your Cancel and Done actions |
|
|
227 | (1) |
|
|
228 | (1) |
|
22.2 MainViewController conformance |
|
|
229 | (2) |
|
22.3 Adding the LioN object to the lion array |
|
|
231 | (3) |
|
Changing the Done button properties |
|
|
233 | (1) |
|
22.4 Setting the like and dislike properties |
|
|
234 | (1) |
|
|
235 | (1) |
|
|
236 | (12) |
|
23.1 Editing existing LioNs |
|
|
236 | (11) |
|
Setting up the AddEditViewController to accept a LioN object to edit |
|
|
237 | (1) |
|
Filling in the text boxes with the LioN name and description |
|
|
238 | (1) |
|
Showing whether the LioN is liked or disliked |
|
|
238 | (3) |
|
Passing the LioN object to the Add/Edit controller |
|
|
241 | (2) |
|
Saving the LioN when the user taps Done, but not creating a new LioN |
|
|
243 | (4) |
|
|
247 | (1) |
|
|
248 | (12) |
|
24.1 Playing in the sandbox |
|
|
248 | (2) |
|
|
250 | (8) |
|
Changing the class definition for the LioN object |
|
|
250 | (3) |
|
Encoding the data for saving |
|
|
253 | (1) |
|
Decoding the data for loading |
|
|
253 | (2) |
|
Adding the loadLions() function |
|
|
255 | (1) |
|
|
256 | (1) |
|
Adding save functionality |
|
|
256 | (2) |
|
24.3 Testing the load and save functionality |
|
|
258 | (1) |
|
|
259 | (1) |
|
25 Making your LioN prettier |
|
|
260 | (13) |
|
|
260 | (11) |
|
|
261 | (2) |
|
Adding the Like and Dislike images |
|
|
263 | (3) |
|
Changing the table view background colors |
|
|
266 | (1) |
|
Toggling the images based on selection |
|
|
267 | (1) |
|
Setting images on the cells |
|
|
268 | (1) |
|
Making the Main View scene prettier |
|
|
269 | (1) |
|
Updating the navigation bars |
|
|
270 | (1) |
|
|
271 | (1) |
|
25.3 Updating the launch scene |
|
|
272 | (1) |
|
|
272 | (1) |
|
26 Working with Auto Layout |
|
|
273 | (12) |
|
26.1 Changing the layout to work for all screen sizes |
|
|
273 | (10) |
|
Make changes to the AddEditView scene |
|
|
275 | (7) |
|
Changing the color of cells on the main scene |
|
|
282 | (1) |
|
|
283 | (2) |
|
|
285 | (12) |
|
27.1 Adding the search functionality |
|
|
285 | (3) |
|
27.2 Filtering LioNs based on user input |
|
|
288 | (6) |
|
Creating the filter function |
|
|
289 | (1) |
|
Filtering the array using a closure |
|
|
289 | (2) |
|
Changing the table view data source |
|
|
291 | (2) |
|
|
293 | (1) |
|
27.3 Searching other fields |
|
|
294 | (1) |
|
|
295 | (1) |
|
27.5 Where do you go from here? |
|
|
295 | (2) |
Appendix A Installing Xcode and Apple developer registration |
|
297 | (3) |
Appendix B Running the app on your device |
|
300 | (3) |
Index |
|
303 | |