Intro, Your brain on iOS Development. |
|
|
|
xxiv | |
|
Metacognition: thinking about thinking |
|
|
xxvii | |
|
Here's what YOU can do to bend your brain into submission |
|
|
xxix | |
|
|
xxx | |
|
The technical review team |
|
|
xxxii | |
|
|
xxxiii | |
1 Going Mobile with iOS |
|
|
So, you want to build an iOS app... |
|
|
2 | (1) |
|
...'cause everyone wants one! |
|
|
3 | (1) |
|
Apps live in an iTunes universe |
|
|
4 | (1) |
|
|
5 | (1) |
|
It all starts with the iPhone SDK |
|
|
6 | (1) |
|
|
7 | (1) |
|
Xcode includes app templates to help you get started |
|
|
8 | (1) |
|
Xcodc is a full-featured IDE |
|
|
9 | (1) |
|
Xcode is the hub of your iOS project |
|
|
10 | (4) |
|
Build your interface within Xcode |
|
|
14 | (1) |
|
Add the button to your view |
|
|
15 | (2) |
|
The iOS simulator lets you test your app on your Mac |
|
|
17 | (1) |
|
|
18 | (1) |
|
|
19 | (4) |
|
You're using the Model View Corn roller pattern |
|
|
23 | (1) |
|
iDecidc is actually a little simpler |
|
|
24 | (2) |
|
|
26 | (1) |
|
Use the GUI editor to connect UI controls to code |
|
|
27 | (1) |
|
A component can trigger certain events |
|
|
28 | (1) |
|
Connect your events to methods |
|
|
29 | (2) |
|
You've built your first iPhone app! |
|
|
31 | (8) |
|
|
39 | (4) |
2 Hello, Renee! |
|
|
First we need to figure out what Mike (really) wants |
|
|
43 | (5) |
|
App design rules—the iOS HIG |
|
|
48 | (3) |
|
HIG guidelines for pickers and buttons |
|
|
51 | (1) |
|
Create a new View-based project for InstaEmail |
|
|
52 | (2) |
|
|
54 | (6) |
|
|
60 | (1) |
|
Use pickers when you want controlled input |
|
|
61 | (1) |
|
Pickers get their data from a datasource... |
|
|
62 | (1) |
|
|
63 | (5) |
|
First, declare that the controller conforms to both protocols |
|
|
68 | (2) |
|
The datasource protocol has two required methods |
|
|
70 | (1) |
|
Connect the datasource just like actions and outlets |
|
|
71 | (1) |
|
There's just one method for the delegate protocol |
|
|
72 | (5) |
|
Actions, outlets, and events |
|
|
77 | (4) |
|
Connect the event to the action |
|
|
81 | (4) |
|
Next, synthesize the property.. |
|
|
85 | (1) |
|
Connect the picker to our outlet |
|
|
86 | (1) |
|
Use your picker reference to pull the selected values |
|
|
87 | (9) |
|
|
96 | (4) |
3 Email needs variety |
|
|
|
100 | (1) |
|
Make room for custom input |
|
|
101 | (2) |
|
Header files describe the interface to your class |
|
|
103 | (6) |
|
Auto-generated accessory also handle memory management |
|
|
109 | (2) |
|
To keep your memory straight, you need to remember just two things |
|
|
111 | (10) |
|
But when Mike's finished typing... |
|
|
121 | (2) |
|
Customize your UITextField |
|
|
123 | (1) |
|
Components that use the keyboard ask it to appear... |
|
|
124 | (1) |
|
Ask the UITextField to give up focus |
|
|
125 | (2) |
|
Messages in Objective-C use named arguments |
|
|
127 | (1) |
|
Use message passing to tell our View Controller when the Done button is pressed |
|
|
128 | (4) |
|
|
132 | (7) |
|
|
139 | (6) |
4 A table with a view |
|
|
So, how do these views fit together? |
|
|
145 | (1) |
|
The navigation template pulls multiple views together |
|
|
146 | (1) |
|
The table view is built in |
|
|
147 | (5) |
|
A table is a collection of cells |
|
|
152 | (8) |
|
Just a few more drinks... |
|
|
160 | (2) |
|
Plists are an easy way to save and load data |
|
|
162 | (3) |
|
Arrays (and more) have built-in support for plists |
|
|
165 | (3) |
|
Use a detail view to drill down into data |
|
|
168 | (1) |
|
A closer look at the detail view |
|
|
169 | (10) |
|
Use the Navigation Controller to switch between views |
|
|
179 | (1) |
|
Navigation Controllers maintain a stack of View Controllers |
|
|
180 | (4) |
|
Dictionaries store information as key-value pairs |
|
|
184 | (3) |
|
Debugging—the dark side of iOS development |
|
|
187 | (1) |
|
First stop on your debugging adventure: the console |
|
|
188 | (1) |
|
Interact with your application while it's running |
|
|
189 | (1) |
|
Xcode supports you after your app breaks, too |
|
|
190 | (1) |
|
The Xcode debugger shows you the state of your application |
|
|
191 | (4) |
|
|
195 | (3) |
5 Refining your app |
|
|
It all started with Sam... |
|
|
198 | (2) |
|
Use the debugger to investigate the crash |
|
|
200 | (3) |
|
Update your code to handle a plist of dictionaries |
|
|
203 | (3) |
|
The Detail View needs data |
|
|
206 | (1) |
|
|
207 | (6) |
|
We have a usability problem |
|
|
213 | (2) |
|
Use a disclosure button to show there are more details available |
|
|
215 | (3) |
|
|
218 | (5) |
|
Use Navigation Controller buttons to add drinks |
|
|
223 | (4) |
|
The button should create a new view |
|
|
227 | (1) |
|
We need a view...but not necessarily a new view |
|
|
228 | (1) |
|
The View Controller defines the behavior for the view |
|
|
229 | (1) |
|
A nib file contains the UI components and connections... |
|
|
230 | (1) |
|
You can subclass and extend view controllers like any other class |
|
|
231 | (5) |
|
Modal views focus the user on the task at hand... |
|
|
236 | (1) |
|
Any view can present a modal view |
|
|
237 | (5) |
|
Our modal view doesn't have a navigation bar |
|
|
242 | (2) |
|
Create the Save and Cancel buttons |
|
|
244 | (1) |
|
Write the Save and Cancel actions |
|
|
245 | (4) |
|
|
249 | (3) |
6 Everyone's an editor... |
|
|
Sam is ready to add a Red-Headed School Girl... |
|
|
252 | (1) |
|
.,.but the keyboard is in the way |
|
|
253 | (2) |
|
Wrap your content in a scroll view |
|
|
255 | (2) |
|
The scroll view is the same size as the screen |
|
|
257 | (3) |
|
The keyboard changes the visible area |
|
|
260 | (2) |
|
iOS notifies you about the keyboard |
|
|
262 | (1) |
|
Register with the default notification center for events |
|
|
263 | (6) |
|
Keyboard events tell you the keyboard state and size |
|
|
269 | (19) |
|
The table view doesn't know its data has changed |
|
|
288 | (4) |
|
The array is out of order, too |
|
|
292 | (8) |
|
Table views have built-in support for editing and deleting |
|
|
300 | (13) |
|
Your iOS Development Toolbox |
|
|
313 | (1) |
|
Sam has another project in mind... |
|
|
314 | (2) |
7 We need more room |
|
|
|
316 | (2) |
|
|
318 | (1) |
|
The HIG covers iPads, too |
|
|
319 | (7) |
|
Use Xcode to build your Universal app |
|
|
326 | (8) |
|
|
334 | (3) |
|
Rotation is key with iPad |
|
|
337 | (8) |
|
A persistent view problem |
|
|
345 | (1) |
|
Don't forget the tableview |
|
|
346 | (13) |
|
Your iOS Development Toolbox |
|
|
359 | (3) |
8 Enterprise apps |
|
|
|
362 | (6) |
|
|
368 | (4) |
|
Choose a template to start iBountyHunter |
|
|
372 | (2) |
|
There's a different structure for universal apps |
|
|
374 | (2) |
|
Drawing how iBountyHunter iPhone works... |
|
|
376 | (1) |
|
...and how it fits with the universal app |
|
|
377 | (5) |
|
Build the fugitive list view |
|
|
382 | (2) |
|
Next up: the Captured view |
|
|
384 | (8) |
|
A view's contents arc actually subviews |
|
|
392 | (2) |
|
After a quick meeting with Bob... |
|
|
394 | (2) |
|
Core Data lets you focus on your app |
|
|
396 | (1) |
|
Core Data needs to know what to load |
|
|
397 | (1) |
|
Core Data describes entities with a Managed Object Model |
|
|
398 | (1) |
|
Build your Fugitive entity |
|
|
399 | (11) |
|
Use an NSFetchRequest to describe your search |
|
|
410 | (7) |
|
Bob's database is a resource |
|
|
417 | (1) |
|
Back to the Core Data stack |
|
|
418 | (1) |
|
The template sets things up for a SQLite DB |
|
|
419 | (2) |
|
|
421 | (1) |
|
The iPhone's application structure defines where you can read and write |
|
|
422 | (1) |
|
Copy the database to the Documents directory |
|
|
423 | (21) |
|
|
444 | (2) |
9 Things are changing |
|
|
|
446 | (3) |
|
Everything stems from our object model |
|
|
449 | (3) |
|
The data hasn't been updated |
|
|
452 | (1) |
|
Data migration is a common problem |
|
|
453 | (1) |
|
Migrate the old data into the new model |
|
|
454 | (1) |
|
Xcode makes it easy to version your data model |
|
|
455 | (2) |
|
Core Data can "lightly" migrate data |
|
|
457 | (4) |
|
Here's what you've done so Far... |
|
|
461 | (1) |
|
Bob has some design input |
|
|
462 | (10) |
|
Your app has a lifecycle all its own... |
|
|
472 | (1) |
|
Multitasking rules of engagement |
|
|
473 | (3) |
|
|
476 | (2) |
|
Use predicates for filtering data |
|
|
478 | (1) |
|
We need to set a predicate on our NSFetchRequest |
|
|
479 | (7) |
|
Core Data controller classes provide efficient results handling |
|
|
486 | (1) |
|
Time for some high-efficiency streamlining |
|
|
487 | (1) |
|
Create the new FetehedResultsController getter method |
|
|
488 | (5) |
|
We need to refresh the data |
|
|
493 | (6) |
|
|
499 | (3) |
10 Proof in the real world |
|
|
For Bob, payment requires proof |
|
|
502 | (9) |
|
|
511 | (10) |
|
There's a method for checking |
|
|
521 | (1) |
|
Prompt the user with action sheets |
|
|
522 | (6) |
|
Bob needs the where, in addition to the when |
|
|
528 | (6) |
|
Core Location can find you in a few ways |
|
|
534 | (2) |
|
|
536 | (8) |
|
just latitude and longitude won't work for Bob |
|
|
544 | (1) |
|
|
545 | (1) |
|
A little custom setup for the map |
|
|
546 | (7) |
|
Annotations require a little more work |
|
|
553 | (1) |
|
Fully implement the annotation protocol |
|
|
554 | (7) |
|
|
561 | (3) |
11 Natural interfaces |
|
|
Bob needs that iPad app, too... |
|
|
564 | (3) |
|
iOS HIG user experience guidelines |
|
|
567 | (1) |
|
Iterate your interface, too |
|
|
568 | (2) |
|
BountyHunterHD is based on a split-view controller |
|
|
570 | (10) |
|
Unifying the custom stuff |
|
|
580 | (5) |
|
It seems we have a problem... |
|
|
585 | (1) |
|
UlWebView has lots of options |
|
|
586 | (2) |
|
HTNIL, CSS and Objective-C |
|
|
588 | (1) |
|
|
588 | (11) |
|
|
599 | (3) |
Appendix I The top 4 things (we didn't cover) |
|
|
#1, Internationalization and Localization |
|
|
602 | (2) |
|
Localizing string resources |
|
|
604 | (2) |
|
|
606 | (1) |
|
|
607 | (1) |
|
Understanding device acceleration |
|
|
608 | (1) |
|
#4. A word or two about gaining... |
|
|
609 | (1) |
|
|
610 | (2) |
Appendix II Get ready for the App Store |
|
|
|
612 | (1) |
|
The Provisioning Profile pulls it all together |
|
|
613 | |
|
Keep track in the Organizer |
|
|
611 | |