iOS Apprentice
Matthijs Hollemans
Copyright ©2016 Razeware LLC.
Notice of Rights
All rights reserved. No part of this book or corresponding materials (such as text,
images, or source code) may be reproduced or distributed by any means without
prior written permission of the copyright owner.
Notice of Liability
This book and all corresponding materials (such as source code) are provided on an
“as is” basis, without warranty of any kind, express of implied, including but not
limited to the warranties of merchantability, fitness for a particular purpose, and
noninfringement. In no event shall the authors or copyright holders be liable for any
claim, damages or other liability, whether in action of contract, tort or otherwise,
arising from, out of or in connection with the software or the use of other dealing in
the software.
Trademarks
All trademarks and registered trademarks appearing in this book are the property of
their own respective owners.
License
By purchasing iOS Apprentice, you have the following license:
• You are allowed to use and/or modify the source code in iOS Apprentice in as
many apps as you want, with no attribution required.
• You are allowed to use and/or modify all art, images and designs that are
included in iOS Apprentice in as many apps as you want, but must include this
attribution line somewhere inside your app: “Artwork/images/designs: from iOS
Apprentice book, available at www.raywenderlich.com”.
• The source code included in iOS Apprentice is for your personal use only. You are
NOT allowed to distribute or sell the source code in iOS Apprentice without prior
authorization.
• This book is for your personal use only. You are NOT allowed to sell this book
without prior authorization, or distribute it to friends, coworkers or students;
they would need to purchase their own copies.
iOS Apprentice
raywenderlich.com 2
About the author
Matthijs Hollemans is a mystic who lives at the top of a mountain
where he spends all of his days and nights coding up awesome
apps. Actually he lives below sea level in the Netherlands and is
pretty down-to-earth but he does spend too much time in Xcode.
Check out his website at www.matthijshollemans.com.
About the cover
Striped dolphins live to about 55-60 years of age, can travel in pods numbering in
the thousands and can dive to depths of 700 m to feed on fish, cephalopods and
crustaceans. Baby dolphins don't sleep for a full a month after they’re born. That
puts two or three sleepless nights spent debugging code into perspective, doesn't
it? :]
iOS Apprentice
raywenderlich.com 3
Table of Contents: Extended
Tutorial 2: Checklists 6..................................................................
Your own to-do app 6.............................................................................................................
Playing with table views 10...................................................................................................
Model-View-Controller 35.....................................................................................................
Adding new items to the checklist 59...................................................................................
The Add Item screen 70..........................................................................................................
Editing existing checklist items 109......................................................................................
Saving and loading the checklist items 126.......................................................................
Multiple checklists 146............................................................................................................
Putting to-do items into the checklists 170..........................................................................
Using UserDefaults to remember stuff 190........................................................................
Improving the user experience 202.....................................................................................
Extra feature: local notifications 233..................................................................................
That’s a wrap! 260..................................................................................................................
iOS Apprentice
raywenderlich.com 5
2
Tutorial 2: Checklists
By Matthijs Hollemans
Your own to-do app
To-do list apps are one of the most popular types of app on the App Store, second
only to fart apps. The iPhone even comes with the Reminders app (but fortunately
no built-in fart app).
Building a to-do list app is somewhat of a rite of passage for budding iOS
developers, so it makes sense that you create one as well.
Your own to-do list app, Checklists, will look like this when you’re finished:
The finished Checklists app
The app lets you organize to-do items into lists and then check off these items once
raywenderlich.com 6