Anyone Can Create an App: Beginning iPhone and iPad programming
By Wendy Wise
()
About this ebook
Do you have a fantastic idea for an iPhone app but no idea how to bring it to life? Great news! With the right tools and a little practice, anyone can create an app. This book will get you started, even if you've never written a line of computer code.
Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.
About the Book
Anyone Can Create an App begins with the basics by introducing programming concepts, the Swift language, and the tools you'll need to write iOS apps. As you explore the interesting examples, illuminating illustrations, and crystal-clear step-by-step instructions, you'll learn to:
- Get started programming, no experience necessary!
- Add controls like text boxes and buttons
- Keep track of your favorite things by creating the Like It or Not (LioN) app
About the Reader
This book is written especially for non programmers - no experience needed!
About the Author
Wendy Wise has an extensive background in mobile and application development and has worked with several Fortune 500 companies. In her 17-year technical career, Wendy has served as a senior director of software development, a senior product manager for international mobile applications, and a hands-on developer for web and mobile technologies, among many other technical roles. Wendy fully embraces her nerd/geek side, as you'll find out as you read this book. In her spare time, she enjoys beer, coffee, photography, camping, and being outdoors.
Table of Contents
-
PART 1 - YOUR VERY FIRST APP
- Getting started
- Building your first app
- Your first app, explained
- Learning more about your development tools: Xcode
- Capturing users' actions: adding buttons
- The button app, explained
- Capturing user input: adding text boxes
- Playing on the Playground PART 2 - THE KEYS TO THE CITY: UNDERSTANDING KEY DEVELOPMENT CONCEPTS
- Go with the flow, man! Controlling the flow of your app
- While you're doing that...
- Collections
- Telling stories with storyboards
- ViewControllers in depth
- Put it on my tab: creating tab bars
- Table views: more than a coffee table picture book
- Patterns: learning to sew PART 3 - CREATING THE LIKE IT OR NOT APP
- Putting it all together: the LioN app
- Adding data to your LioN app
- Displaying details of your LioN
- Creating the details of the detail view
- The AddEditView scene
- Delegates are everywhere
- Editing LioNs
- Saving LioNs
- Making your LioN prettier
- Working with Auto Layout
- Search your LioNs
Wendy Wise
Wendy Wise has an extensive background in mobile and application development and has worked with several Fortune 500 companies. In her 17-year technical career, Wendy has served as a senior director of software development, a senior product manager for international mobile applications, and a hands-on developer for web and mobile technologies, among many other technical roles. Wendy fully embraces her nerd/geek side, as you'll find out as you read this book. In her spare time, she enjoys beer, coffee, photography, camping, and being outdoors.
Related to Anyone Can Create an App
Related ebooks
iPad App Guide: How To Create Your Own Ipad App and Make An Amazing Income Stream Rating: 0 out of 5 stars0 ratingsiOS Programming Cookbook Rating: 0 out of 5 stars0 ratingsCreating Mobile Apps with Appcelerator Titanium Rating: 0 out of 5 stars0 ratingsHow To Program A Mobile Game Rating: 4 out of 5 stars4/5Beginning iOS Programming For Dummies Rating: 0 out of 5 stars0 ratingsDesigning for the iPad: Building Applications that Sell Rating: 5 out of 5 stars5/5How To Create An App Rating: 3 out of 5 stars3/5iOS 10 Programming for Beginners Rating: 4 out of 5 stars4/5IOS Programming For Beginners: The Simple Guide to Learning IOS Programming Fast! Rating: 0 out of 5 stars0 ratingsiPhone User Interface Cookbook Rating: 0 out of 5 stars0 ratingsApp Inventor for Android: Build Your Own Apps - No Experience Required! Rating: 5 out of 5 stars5/5Programming with Swift 4.2: Building iOS Apps with Swift, #1 Rating: 0 out of 5 stars0 ratingsiPad Application Development For Dummies Rating: 3 out of 5 stars3/5Game Development with Swift Rating: 5 out of 5 stars5/5Learning iOS UI Development: Implement complex iOS user interfaces with ease using Swift Rating: 0 out of 5 stars0 ratingsApp Development For Beginners: Secrets to Success Selling Apps on the Google Play Store Rating: 5 out of 5 stars5/5The Small Business Guide to Apps: How your business can use apps to increase market share and retain more customers Rating: 0 out of 5 stars0 ratingsCreating Apps: The Guide for Ordinary People Rating: 0 out of 5 stars0 ratingsAppvertising - How Apps Are Changing The World Rating: 5 out of 5 stars5/5HTML5 Game Development HOTSHOT Rating: 0 out of 5 stars0 ratingsBuild a Whatsapp Like App in 24 Hours: Create a Cross-Platform Instant Messaging for Android Rating: 4 out of 5 stars4/5Destroyed In Seconds: 10 Mistakes That Will Destroy Your Website Rating: 0 out of 5 stars0 ratingsMobile App Growth Hacks: Developer Interviews iOS 8 Rating: 0 out of 5 stars0 ratingsApp Design Basics for Professionals Rating: 0 out of 5 stars0 ratingsContent Creation in the Metaverse: Evlove With the Times: MFI Series1, #55 Rating: 0 out of 5 stars0 ratingsAPP MARKETING: Top Mobile App Monetization and Promotion Strategies Rating: 0 out of 5 stars0 ratingsPhoneGap By Example Rating: 5 out of 5 stars5/5Generating Creative Images With DALL-E 3: Create accurate images with effective prompting for real-world applications Rating: 0 out of 5 stars0 ratingsFreelance Web Developer 101: How to Start, Grow, and Succeed in Freelance Web Development from A to Z Rating: 1 out of 5 stars1/5A Quick Guide To Attracting More Business With Mobile Apps Rating: 0 out of 5 stars0 ratings
Programming For You
Python: Learn Python in 24 Hours Rating: 4 out of 5 stars4/5Excel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5Linux: Learn in 24 Hours Rating: 5 out of 5 stars5/5SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5Python Data Structures and Algorithms Rating: 5 out of 5 stars5/5JavaScript All-in-One For Dummies Rating: 5 out of 5 stars5/5Microsoft Azure For Dummies Rating: 0 out of 5 stars0 ratingsPython Programming : How to Code Python Fast In Just 24 Hours With 7 Simple Steps Rating: 4 out of 5 stars4/5SQL All-in-One For Dummies Rating: 3 out of 5 stars3/5Learn to Code. Get a Job. The Ultimate Guide to Learning and Getting Hired as a Developer. Rating: 5 out of 5 stars5/5Algorithms For Dummies Rating: 4 out of 5 stars4/5Learn SQL in 24 Hours Rating: 5 out of 5 stars5/5PYTHON: Practical Python Programming For Beginners & Experts With Hands-on Project Rating: 5 out of 5 stars5/5Excel 101: A Beginner's & Intermediate's Guide for Mastering the Quintessence of Microsoft Excel (2010-2019 & 365) in no time! Rating: 0 out of 5 stars0 ratingsPython for Data Science For Dummies Rating: 0 out of 5 stars0 ratingsGodot from Zero to Proficiency (Foundations): Godot from Zero to Proficiency, #1 Rating: 5 out of 5 stars5/5PYTHON PROGRAMMING Rating: 4 out of 5 stars4/5Learn NodeJS in 1 Day: Complete Node JS Guide with Examples Rating: 3 out of 5 stars3/5Learn PowerShell in a Month of Lunches, Fourth Edition: Covers Windows, Linux, and macOS Rating: 5 out of 5 stars5/5
Reviews for Anyone Can Create an App
0 ratings0 reviews
Book preview
Anyone Can Create an App - Wendy Wise
Copyright
For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact
Special Sales Department
Manning Publications Co.
20 Baldwin Road
PO Box 761
Shelter Island, NY 11964
Email:
©2017 by Manning Publications Co. All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps.
Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine.
Development editor: Christina Taylor
Technical development editor: Robin Dewson
Review editor: Ozren Harlovic
Project editor: Tiffany Taylor
Copy editor: Corbin Collins
Proofreader: Melody Dolab
Technical proofreader: Scott Steinman
Typesetter: Dennis Dalinnik
Cover designer: Leslie Haimes
ISBN: 9781617292651
Printed in the United States of America
1 2 3 4 5 6 7 8 9 10 – EBM – 22 21 20 19 18 17
Dedication
To my wife, who so patiently puts up with me.
To my parents, who so patiently put up with me for all those years.
And to the rest of my friends and family, who put up with me,
although sometimes not as patiently as I would like.
Brief Table of Contents
Copyright
Brief Table of Contents
Table of Contents
Preface
Acknowledgments
About this Book
1. Your very first app
Chapter 1. Getting started
Chapter 2. Building your first app
Chapter 3. Your first app, explained
Chapter 4. Learning more about your development tools: Xcode
Chapter 5. Capturing users’ actions: adding buttons
Chapter 6. The button app, explained
Chapter 7. Capturing user input: adding text boxes
Chapter 8. Playing on the playground
2. The keys to the city: understanding key development concepts
Chapter 9. Go with the flow, man! Controlling the flow of your app
Chapter 10. While you’re doing that...
Chapter 11. Collections
Chapter 12. Telling stories with storyboards
Chapter 13. ViewControllers in depth
Chapter 14. Put it on my tab: creating tab bars
Chapter 15. Table views: more than a coffee table picture book
Chapter 16. Patterns: learning to sew
3. Creating the Like it or Not app
Chapter 17. Putting it all together: the LioN app
Chapter 18. Adding data to your LioN app
Chapter 19. Displaying details of your LioN
Chapter 20. Creating the details of the detail view
Chapter 21. The AddEditView scene
Chapter 22. Delegates are everywhere
Chapter 23. Editing LioNs
Chapter 24. Saving LioNs
Chapter 25. Making your LioN prettier
Chapter 26. Working with Auto Layout
Chapter 27. Search your LioNs
Appendix A. Installing Xcode and Apple developer registration
Appendix B. Running the app on your device
Overview
Topics covered
Index
List of Figures
Table of Contents
Copyright
Brief Table of Contents
Table of Contents
Preface
Acknowledgments
About this Book
1. Your very first app
Chapter 1. Getting started
1.1. The big picture: iPhone and iPad development
1.1.1. Some key terms
1.1.2. Am I developing or programming?
1.1.3. Objectively Swift
1.1.4. Apps you’ll create
1.2. Learning what you need to remember
1.2.1. Understanding and remembering key concepts
1.2.2. Syntax
1.2.3. The importance of pseudocode
1.3. What you need to create apps for iPhones and iPads
1.3.1. You’re going to need a Mac
1.3.2. Xcode: the iPhone and iPad development environment
1.3.3. Helpful resources
1.4. Summary
Chapter 2. Building your first app
2.1. Launching Xcode for the first time
2.1.1. Step 1: Launch Xcode
2.1.2. Step 2: Create a new project
2.1.3. Step 3: Set up your project options
2.1.4. Step 4: Run the blank app
2.1.5. Step 5: Add the Hello World text
2.1.6. Step 6: Run the app
2.1.7. Step 7: Pat yourself on the back (and review)
2.2. Summary
Chapter 3. Your first app, explained
3.1. Xcode templates, explained
3.2. Understanding the single-view application
3.3. A label, defined
3.4. The Simulator, defined
3.4.1. Running Hello World in the Simulator
3.5. Summary
Chapter 4. Learning more about your development tools: Xcode
4.1. Xcode panels explained
4.1.1. Standard Editor
4.1.2. Utilities panel
4.1.3. Main.storyboard
4.1.4. Navigator panel
4.2. Xcode icons explained
4.3. Feel free to explore
4.4. Summary
Chapter 5. Capturing users’ actions: adding buttons
5.1. Adding a label and a button
5.1.1. Step 1: Start a new project using the Single View Application template
5.1.2. Step 2: Add a button and label to the storyboard, and run the app to test it
5.1.3. Step 3: Connect the button and the label to the code (wire them up), and run the app to test it
5.1.4. Step 4: Add code to change the text on the Label when the button is clicked, and run the app to test it
5.2. Changing how the label appears
5.2.1. Step 5: Change how the label looks, and run the app to test it
5.3. Summary
Chapter 6. The button app, explained
6.1. The button, explained
6.1.1. Creating outlets (or How do I contact Butch?
)
6.1.2. Creating actions
6.1.3. Is Xcode clairvoyant?
6.1.4. User interfaces and the front end of apps
6.2. Documentation
6.3. Commenting: you can never be too wordy, can you?
6.3.1. Comments are your friends
6.3.2. How to comment your code
6.4. Summary
Chapter 7. Capturing user input: adding text boxes
7.1. Adding text fields
7.1.1. Step 1: Create a new single-view application
7.1.2. Step 2: Add a button and a label to the view
7.1.3. Step 3: Add a text field to the view
7.1.4. Step 4: Connect the button, label, and text box to the code (wire them up), and test the app
7.1.5. Step 5: Add code to change the label, and test the app
7.1.6. Step 6: Comment the code
7.2. Summary
Chapter 8. Playing on the playground
8.1. Swift Playgrounds: learning to interact with others
8.2. Frameworks
8.3. Types of variables
8.3.1. Not your shoestrings
8.3.2. Going back to math class
8.3.3. Double, double, toil and trouble
8.4. Summary
2. The keys to the city: understanding key development concepts
Chapter 9. Go with the flow, man! Controlling the flow of your app
9.1. Control your flow
9.2. If you do that again, I’m going to...
9.3. If you do that OR if you... then I’m going to...
9.4. If you do that AND you do this, I will...
9.5. If you do this, else if you do this, else if you do this...
9.5.1. Printing a line with values of variables and strings
9.6. If you do that, otherwise...
9.7. Summary
Chapter 10. While you’re doing that...
10.1. Using the while statement to control your code
10.1.1. The while statement in action
10.1.2. Wrapping up the while statement discussion
10.2. Turn around now switch (remember Will Smith?)—the switch statement
10.2.1. Assignment
10.3. How many fingers am I holding up?
10.3.1. Step 1: Add all the components to the storyboard
10.3.2. Step 2: Make the storyboard connections
10.3.3. Step 3: Create a variable to capture the number guessed: numberGuessed
10.3.4. Step 4: Change the numberGuess variable when the stepper is tapped
10.3.5. Connecting the Guess! button
10.4. Summary
Chapter 11. Collections
11.1. Quantum arrays: not really, but that sounds **br/** scary, right?
11.2. The for statement and loop
11.3. Dictionaries
11.4. Creating a state name lookup app
11.4.1. Step 1: Create an app named StateAbbreviationLookup
11.4.2. Step 2: Add the UI components to the storyboard
11.4.3. Step 3: Connect the UI components to the code
11.4.4. Step 4: Create the dictionary of state abbreviations and names
11.4.5. Step 5: Create the code to look up the state abbreviation when the user types in the state name
11.5. Summary
Chapter 12. Telling stories with storyboards
12.1. Storyboards
12.2. Creating an example storyboard app
12.2.1. Step 1: Create a new app called StoryboardExample
12.2.2. Step 2: Add a second scene to the app
12.2.3. Step 3: Add a navigation bar to the second scene
12.2.4. Step 4: Link the Cancel button to the first scene
12.3. Segue animation types
12.4. Summary
Chapter 13. ViewControllers in depth
13.1. Inheritance
13.2. The override keyword
13.3. ViewController lifecycles
13.4. The Lifecycle app
13.4.1. Step 1: Create a new project called Lifecycle
13.4.2. Step 2: Add a second ViewController
13.4.3. Step 3: Create an unwind segue
13.4.4. Step 4: Override the five functions
13.4.5. Step 5: Test the app
13.5. Summary
Chapter 14. Put it on my tab: creating tab bars
14.1. The Tab Bar Controller
14.1.1. Step 1: Create a new app
14.1.2. Step 2: Delete the existing scene
14.1.3. Step 3: Add a Tab Bar Controller to the storyboard
14.1.4. Step 4: Add labels to the different tabs
14.1.5. Step 5: Add a third tab to the app
14.2. Summary
Chapter 15. Table views: more than a coffee table picture book
15.1. Delegation
15.1.1. Making pizza from scratch
15.1.2. Delegating pizza making
15.2. Protocols
15.3. Data sources
15.4. Creating a table view app
15.4.1. Step 1: Create a new app
15.4.2. Step 2: Add a table view to the ViewController
15.4.3. Step 3: Set up a prototype cell
15.4.4. Step 4: Set the protocols for UITableView
15.4.5. Step 5: Create a data source for the pizza
15.4.6. Step 6: Connect the data to a table
15.5. Summary
Chapter 16. Patterns: learning to sew
16.1. Design patterns, defined
16.1.1. Clean code
16.1.2. Understandable
16.1.3. Maintainable
16.1.4. Extensibility
16.2. Types of design patterns
16.2.1. Model-View-Controller design pattern
16.2.2. Delegate pattern
16.2.3. The Memento pattern
16.3. Summary
3. Creating the Like it or Not app
Chapter 17. Putting it all together: the LioN app
17.1. Like it or Not
17.2. Getting started
17.2.1. Creating the app
17.2.2. Adding a Navigation Controller
17.2.3. Adding an iPhone 4s Simulator
17.2.4. Connecting the data to the table view
17.2.5. Implement the functions for table views
17.3. Summary
Chapter 18. Adding data to your LioN app
18.1. Adding hardcoded data to your LioN
18.1.1. Creating an array of dummy data
18.1.2. Wiring lionData to the table view with hardcoded data
18.2. Adding a model to the mix
18.2.1. Adding a new Swift file to the project
18.3. Changing the layout of the table cell
18.3.1. Changing the cell in the storyboard to show the description
18.3.2. Updating the function to show the description
18.4. Summary
Chapter 19. Displaying details of your LioN
19.1. Capturing the tapped row index
19.2. Adding a detail page to the storyboard
19.2.1. Adding a ViewController to the storyboard
19.2.2. Creating a new ViewController class
19.3. Passing data to the DetailViewController
19.3.1. Preparing the DetailViewController to accept the LioN
19.3.2. Updating the MainViewController to pass data
19.4. Summary
Chapter 20. Creating the details of the detail view
20.1. Adding some labels to your detail screen
20.1.1. Converting an Int to a string using the description
20.1.2. Converting an Int to a string using String
20.2. Adding new LioNs to the list
20.2.1. Adding the + button to the view
20.2.2. Creating a function to handle the action and link the **br/** two together
20.2.3. Adding hardcoded values to the LioN list
20.2.4. Deleting LioNs from the list
20.3. Summary
Chapter 21. The AddEditView scene
21.1. Creating a new detail view
21.1.1. Adding a new Table ViewController
21.1.2. Adding a new AddEditViewController class
21.1.3. Hooking up the Cancel and Done buttons
21.1.4. Checkpoint
21.2. Adding new LioNs
21.2.1. Don’t allow the cell to be selected
21.2.2. Setting the keyboard behaviors
21.2.3. Dismissing the keyboard on user tap
21.3. Summary
Chapter 22. Delegates are everywhere
22.1. Connecting your views
22.1.1. Implementing the protocol
22.1.2. Updating your Cancel and Done actions
22.1.3. Capturing the user input
22.2. MainViewController conformance
22.3. Adding the LioN object to the lion array
22.3.1. Changing the Done button properties
22.4. Setting the like and dislike properties
22.5. Summary
Chapter 23. Editing LioNs
23.1. Editing existing LioNs
23.1.1. Setting up the AddEditViewController to accept a LioN object **br/** to edit
23.1.2. Filling in the text boxes with the LioN name and description
23.1.3. Showing whether the LioN is liked or disliked
23.1.4. Passing the LioN object to the Add/Edit controller
23.1.5. Saving the LioN when the user taps Done, but not creating a new LioN
23.2. Summary
Chapter 24. Saving LioNs
24.1. Playing in the sandbox
24.2. Saving your data
24.2.1. Changing the class definition for the LioN object
24.2.2. Encoding the data for saving
24.2.3. Decoding the data for loading
24.2.4. Adding the loadLions() function
24.2.5. Loading summary
24.2.6. Adding save functionality
24.3. Testing the load and save functionality
24.4. Summary
Chapter 25. Making your LioN prettier
25.1. Basic fixes
25.1.1. Creating two sections
25.1.2. Adding the Like and Dislike images
25.1.3. Changing the table view background colors
25.1.4. Toggling the images based on selection
25.1.5. Setting images on the cells
25.1.6. Making the MainView scene prettier
25.1.7. Updating the navigation bars
25.2. Adding an icon
25.3. Updating the launch scene
25.4. Summary
Chapter 26. Working with Auto Layout
26.1. Changing the layout to work for all screen sizes
26.1.1. Make changes to the AddEditView scene
26.1.2. Changing the color of cells on the main scene
26.2. Summary
Chapter 27. Search your LioNs
27.1. Adding the search functionality
27.2. Filtering LioNs based on user input
27.2.1. Creating the filter function
27.2.2. Filtering the array using a closure
27.2.3. Changing the table view data source
27.2.4. Polishing the app
27.3. Searching other fields
27.4. Summary
27.5. Where do you go from here?
Appendix A. Installing Xcode and Apple developer registration
A.1 Downloading and installing Xcode
A.2 Apple requirements for iPhone and iPad development
Appendix B. Running the app on your device
Overview
Topics covered
Index
List of Figures
Preface
I’m incredibly excited to have finally completed this book. I want to see more people learning to program, but some are intimidated by the enormous world of programming and have trouble finding a good place to start. I hope this book will help.
I didn’t major in Computer Science in college, so I probably started my computer career somewhere close to where you are now. I got my first iPhone when they came out in 2007, and I was enamored. I wanted to create my own apps, so I found a local class that taught iOS programming, and away I went. I’ve been programming on the iPhone in some fashion ever since.
One of the things you’ll notice after you begin programming is that your friends will frequently mention that they have a great idea for an app. Then they’ll ask if you can create it for them, and they’ll promise you a share of what they’re sure will be huge profits. I’ve received so many of these requests that my general response includes telling people they should learn to create the app themselves. They usually follow up with a comment or two about not knowing where to start, not being smart enough, their brain not working like that, or programming being too hard. I constantly deny these things—writing an app isn’t rocket science, and I think everyone can do it, given the time and the tools.
I’ve also been involved in a lot of women’s initiatives: specifically, trying to encourage more girls and women to get into science, technology, engineering, and math (STEM) areas. This STEM interest, combined with my friends asking if I could help them create an app, led me to want to write a book for absolute beginner programmers. This book isn’t written just for girls and women, but that was definitely an inspiration when I began.
Why Manning? Well, I had purchased many Manning books in the past, and they were high quality. And many years ago, I volunteered to review draft manuscripts; I’ve reviewed several, so I was familiar (at a very high level) with the publishing process. As soon as I decided to write the book, I knew it had to be with Manning. I submitted my idea for the book, waited for a few weeks, and then received word that Manning wanted me to write it! Let the panic ensue!
This has been a long, fun journey—one that I wouldn’t trade for anything. It’s been a labor of love, joy, panic, long nights, stress, and happiness. This is the first book I’ve ever written, so I appreciate your reading it, and I hope you enjoy it.
Remember: you are smart enough, and your brain will understand this topic. Be patient—you can do it!
Acknowledgments
There are many people to thank for helping make this crazy dream of mine a reality. Thank you to my biggest supporter: my wife, Jocelyn Whitfield. You believed in me, supported me, encouraged me, and picked me up when I was down. I absolutely could not have completed this book without you. Thank you to my parents for also encouraging me, helping me, and, of course, raising me! Thank you to all of my family and friends, as well. You don’t know just how much your love and support helped me, especially Clay, Kristine, Nancy, and Ja. I love you all!
I also want to thanks the wonderful people at Manning who made this book possible: publisher Marjan Bace and everyone on the editorial and production teams, including Christina Taylor, Janet Vail, Tiffany Taylor, Corbin Collins, Melody Dolab, Dennis Dallinik, and many others who worked behind the scenes.
I can’t thank enough the amazing group of technical peer reviewers led by Ozren Harlovic—Stephen Byrne, Mark Cooper, Igor Delovski, Olivier Ducatteeuw, Laurence Giglio, Pieter Gyselinck, Marius Horga, Jocelyn Jeriah, Kelvin Meeks, Drew Monrad, Jason Pike, and Stuart Woodward—and the talented forum contributors. Their contributions included catching technical mistakes, errors in terminology, and typos, and making topic suggestions. Each pass through the review process and each piece of feedback implemented through the forum topics shaped and molded the manuscript. Special thanks to Robin Dewson, who served as the book’s technical editor, and Scott Steinman, who served as the book’s technical proofreader.
About this Book
I assume you bought this book because you want to learn how to make an iOS app but you’ve never done any coding before (that, or you know me and want to support me!). Either way, you’re going to learn a lot and have fun in the process. The book is meant for people who have never written any code, or who have coded a little something but definitely not an iOS app. It also assumes that you have the patience to read the book, try the examples, and then rework the examples if they didn’t work perfectly the first time. That’s a lot of what coding is: debugging. Even the best developers miss things, so don’t get frustrated when your code doesn’t work exactly right the first time. Patience, Grasshopper.
Why iOS apps? If you tell your friends that you’re learning iOS (or Swift, or developing for Apple phones), they may say, Wow, I heard that was pretty hard. Why don’t you start with something easier?
Your answer can be, Well, I have an idea for an app, and I have the patience and willingness to learn. Ergo, I will.
People may encourage you to learn something easier, like Hypertext Markup Language (HTML, used in web pages and such). That’s all well and good, but you really wanted to learn to create apps for Apple devices (using Swift), so you’re reading this book. I’m here to tell you, you can start with iOS, and you can learn to write apps; and with time, patience, and resolve, you can be an expert someday if you want to be.
My goal in this book is to give you just enough of what you need to know to complete the next step, without overwhelming you with a lot of things you don’t need to know right now. In other words, I’m trying to teach this subject with just-in-time learning techniques. This means although there may be pages and pages of stuff you could learn about a topic, you don’t need to learn all of that up front. I take all of those pages and distill them down into smaller portions of what you really need to know in order to get started.
Many people are leery of learning to program. The programming world is huge—there are many languages and many acronyms, and it seems as though some programmers haven’t seen the Sun in years. Rest assured, you can get started by learning just the basics, and I’ll walk you through the acronyms and the programmer jargon. Think of programming as just another hobby at this point. You can spend as much or as little time on it as you want, but the more time you devote, the better you’ll be at it. Imagine me accompanying you on the path—we’ll get there together.
Every developer begins slowly, learning the fundamentals. Even the most seasoned programmer had to start somewhere! There isn’t a club
that only allows certain people to be developers. Everyone can do it, including you. Take the time to learn the basics, understand the concepts, and work through the exercises, and soon you’ll be an iOS developer, too.
Who is this book is written for?
This book is for absolute programming beginners who’ve never written a line of code and don’t know the underlying concepts for doing so. I make these assumptions:
You have no development experience.
You want to learn to make iOS applications.
You have a Mac on which you can code, or you are willing to purchase a Mac.
You have patience.
I hope this book proves to be the perfect place for you to begin, because I know you can do it!
Who is this book not written for?
If you’re a developer and are already familiar with concepts such as for loops, while loops, and if statements, and you just want to learn more about iOS, this probably isn’t the book for you. You can find other books that teach the syntax of Swift and differences between mobile development and other platform development, and you’ll probably get bored with this book pretty quickly. But if you’re a programmer and are only familiar with languages like HTML or COBOL, you can definitely learn something from this book.
Roadmap
The book is broken into three parts:
Part 1 (chapters 1–8)—This is the beginning of your programming career. You’ll learn the basics of how programming works, you’ll be introduced to Xcode and the Swift Playground, and you’ll write a few simple apps to get started.
Part 2 (chapters 9-16)—These chapters will teach you about some additional skills and concepts needed to create apps, including the while statement, the switch statement, arrays and collections, storyboards, ViewControllers, and tables. Part 2 is more advanced than part 1, so make sure you understand part 1 first.
Part 3 (chapters 17-27)—In these chapters, you’ll create a LioN (Like it or Not) app. The LioN app allows the user to add items to a list and rate whether they like those items. When I’m at the store, I can never remember which toothpaste I like; so, I open the LioN app and search for toothpaste, and the app shows me which toothpaste I like. The app will serve as a complete example you can follow as you go on to create your own apps.
Source code downloads
You can download all the projects from this book and refer to them anytime. They’re available at the Manning website (www.manning.com/books/anyone-can-create-an-app) and on GitHub (https://github.com/wlwise/AnyoneCanCreateAnApp).
Software/hardware requirements
Here’s what you need to get started:
A Mac computer—Chapter 1 gives you the basic requirements if you don’t have a Mac already.
Xcode—This integrated development environment (IDE) is the primary tool you’ll need to create apps. You probably already use a program like Microsoft Word to create documents. Well, Xcode is the application you use to create programs. Appendix A has instructions for installing this free tool, which you’ll begin using in chapter 2. I’ll also go into more detail about Xcode in chapter 4.
A membership in the Apple Developer Program—Appendix A explains how to join. There are two options: a free membership (which I recommend) and a $99 membership.
Online resources
The resource that will provide you with the most help with this book is the book’s website: www.manning.com/books/anyone-can-create-an-app. You can download the examples, ask questions about the exercises in the Author Online forum, and chat with other readers. I’ll try to be as responsive as possible and answer your forum questions, and of course you can tell me what you think of this book.
Apple is another great place to explore, including the resources in the Apple Developer Member Center (http://mng.bz/3OjD). You’ll need to be a member of the Apple Developer Program; see appendix A for more info. You do not need to read these documents to use this book—I’m just providing the location in case you want to learn more about a topic. The Getting Started resources are a good place to start, and the Guides section is another good type of resource is the Guides section.
Stack Overflow (www.stackoverflow.com) is another great place to get answers about specific questions. You can search on your exact need, and it’s almost guaranteed that someone has asked the question before and someone else has answered it. Be as specific as possible when searching, or you’ll get back an excess of information.
About the author
Wendy Wise has an extensive background in mobile and application development and has worked with several Fortune 500 companies. In her 17-year technical career, Wendy has served as a senior director of software development, a senior product manager for international mobile applications, and a hands-on developer for web and mobile technologies, among many other technical roles. Wendy fully embraces her nerd/geek side, as you’ll find out as you read this book. In her spare time, she enjoys beer, coffee, photography, camping, and being outdoors.
Author Online
Purchase of Anyone Can Create an App includes free access to a private web forum run by Manning Publications where you can make comments about the book, ask technical questions, and receive help from the author and from other users. To access the forum and subscribe to it, point your web browser to www.manning.com/books/anyone-can-create-an-app. This page provides information on how to get on the forum once you’re registered, what kind of help is available, and the rules of conduct on the forum.
Manning’s commitment to our readers is to provide a venue where a meaningful dialogue between individual readers and between readers and the author can take place. It’s not a commitment to any specific amount of participation on the part of the author, whose contribution to Author Online remains voluntary (and unpaid). We suggest you try asking the author some challenging questions, lest her interest stray! The Author Online forum and the archives of previous discussions will be accessible from the publisher’s website as long as the book is in print.
Part 1. Your very first app
Part 1 introduces you to the basic concepts of programming and aims to quickly get your feet wet in the programming world. You’ll create your first app in chapter 2 and then in chapter 3 learn more about what you did and why you did it. Chapter 4 walks you through the tool (Xcode) that you use to create apps. You’ll go deeper into the programming world in chapters 5–7 by adding buttons and text boxes. Finally, in chapter 8, you’ll learn about an exciting tool called the Swift Playground, which allows you to learn and test code quickly and easily.
Chapter 1. Getting started
This chapter covers
An overview of creating iPhone and iPad apps
Learning strategy—what to remember
What you’ll need to create apps for iOS
The world is continuously evolving, and the movement to mobile-first is part of that evolution. What is mobile-first? It’s the idea that many people use their iPhones or iPads as their main source of information—whether for email, news, social media, the internet, shopping, texting, or phone calls. Because of this, companies are considering how to provide that information on a mobile device (like an iPhone and iPad) first, rather than the old way, which was to make a web page first and then add mobile device applications (apps) to support it.
It’s an exciting time for technology growth and evolution, and you’re going to be a part of that. This book will teach you what you need to know to get started creating apps for iPhones and iPads. It assumes you have no previous development experience and that this is your first foray into the wonderful world of app creation. If you’ve developed apps before, some if this information may be familiar because we’re starting from the beginning, but everyone can use a refresher every now and then, right?
1.1. The big picture: iPhone and iPad development
Creating apps for iPhones and iPads is exciting. I understand that even thinking of creating apps for these powerful devices may seem daunting, but rest assured that we’re going to do this together, and you’ll complete several applications by the time you’re finished with this book. Making apps for iPhones and iPads is complex enough that it has its own vocabulary, which I’ll teach you.
Creating an app is known as developing software, and by the time you’re finished with this book, you’ll have developed several apps and will have a beginner’s knowledge of software terms and basics. Let’s start with the absolute basics to make sure we’re on the same page (pun intended).
1.1.1. Some key terms
First of all, learning to develop for iPhones and iPads means you’ll create apps that can be installed on and run only on iPhones and iPads. These applications can’t run on any other devices, so make sure you understand what you’re getting into. You’ll learn to develop applications to run on iOS, which is the operating system (OS) that runs on iPhones and iPads. An operating system is the underlying software that runs on machines—like Windows 95 (going old school!), Windows 8.1, or Mac OS X (now macOS). These operating systems do all the hard work of interacting with the electronic components that make up a computer, so you have to interact with the OS instead of trying to tell the computer what you mean when you press a key. The early chapters of this book cover the key concepts of developing for both iPhones and iPads, but the first examples will focus on iPhones. Developing for iPads is not that different, and I’ll show you the differences as we move into later chapters.
1.1.2. Am I developing or programming?
The term development is synonymous with programming because you’re learning to develop or program apps that will make a computer do stuff. There are many, many programming language options to choose from. A programming language is a formally constructed language used to communicate with a machine. When Apple created the iPhone, it created a language called Objective-C (the programming language used before Swift) that, when used by a programmer and compiled or translated by a compiling program called a compiler (more on that later), can be understood and acted upon by the iPhone. Figure 1.1 shows this programming language at work.
Figure 1.1. The app-creation process (the birds and bees of apps)
As the figure shows, using a programming language to create an app for an iPhone or iPad involves the following steps:
You type words on the screen, which are commands or code.
The compiler takes those words, and, if there are no errors in the program, translates them into a language that the machine can understand.
Learning to program is much like learning a foreign language. You need to understand the words and their meaning, and then you must put them together in the right order to form sentences.
1.1.3. Objectively Swift
As mentioned, there are