Chapters

Hide chapters

iOS Apprentice

Eighth Edition · iOS 13 · Swift 5.2 · Xcode 11

Getting Started with SwiftUI

Section 1: 8 chapters
Show chapters Hide chapters

My Locations

Section 4: 11 chapters
Show chapters Hide chapters

Store Search

Section 5: 13 chapters
Show chapters Hide chapters

1. Introduction
Written by Joey deVilla

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

Hi, welcome to The iOS Apprentice: Beginning iOS Development with Swift, Eighth Edition, the swiftest way (pardon the pun) to iOS development mastery!

In this book, you’ll learn how to make your own iPhone and iPad apps using Apple’s Swift programming language, Xcode 11, and the SwiftUI and UIKit user interface frameworks. You’ll do this by building four interesting iOS apps.

The apps you’ll make in The iOS Apprentice
The apps you’ll make in The iOS Apprentice

Everybody likes games, right? So you’ll start by building a simple but fun iPhone game named Bullseye that will teach you the basics of iPhone programming. The other apps will build on what you learn there.

Taken together, the four apps that you’ll build cover everything you need to know to make your own apps. By the end of the book, you’ll be experienced enough to turn your ideas into real apps that you can put on the App Store!

If you’ve never programmed before or you’re new to iOS, don’t worry. You should be able to follow along with the step-by-step instructions and understand how to make these apps. Each chapter has a ton of illustrations to keep you from getting lost. Not everything might make sense right away, but hang in there and all will become clear in time.

Writing your own iOS apps is a lot of fun, but it’s also hard work. If you have the imagination and perseverance, there’s no limit to what you can make your apps do. It’s my sincere belief that this book can turn you from a complete newbie into an accomplished iOS developer, but you do have to put in the time and effort. By writing this book, I’ve done my part. The rest is up to you…

About this book

The iOS Apprentice will help you become an excellent iOS developer, but only if you let it. Here are some tips that will help you get the most out of this book.

Learn through repetition

You’re going to make several apps in this book. Even though the apps are quite simple, you may find the instructions hard to follow at first — especially if you’ve never done any computer programming before. You’ll be facing a lot of new concepts.

Follow the instructions yourself

It’s important that you not just read the instructions, but also actually follow them. Open Xcode, type in the source code fragments and run the app in the simulator as instructed. This helps you to see how the app develops, step by step.

Don’t panic — bugs happen!

You’ll run into problems, guaranteed. Your programs will have strange bugs that will leave you stumped. Trust me, I’ve been programming for 30 years and that still happens to me, too. We’re only humans and our brains have a limited capacity to deal with complex programming problems. In this book, I’ll give you tools for your mental toolbox that will allow you to find your way out of any hole you’ve dug for yourself.

Understanding beats copy-pasting

Too many people attempt to write iOS apps by blindly copy-pasting code that they find on blogs and other websites, without really knowing what that code does or how it should fit into their programs.

Do the exercises

I’ll also ask you to do some thinking of your own — yes, there are exercises! It’s in your best interest to actually do these exercises. There’s a big difference between knowing the path and walking the path… And the only way to learn programming is to do it.

Have fun!

Last but not least, remember to have fun! Step by step, you’ll build your understanding of programming while making fun apps. By the end of this book, you’ll have learned the essentials of Swift, the iOS Software Development Kit (SDK) and both the SwiftUI and the UIKit frameworks. More importantly, you should have a pretty good idea of how everything goes together and how to think like a programmer.

Is this book right for you?

Whether you’re completely new to programming or you come from a different programming background and want to learn iOS development, this book is for you!

iOS 13 and later only

The code in this book is written exclusively for iOS version 13 and later. Each new release of iOS is such a big departure from the previous one that it doesn’t make sense to keep developing for older devices and iOS versions. Things move quickly in the world of mobile computing!

What you need

It’s a lot of fun to develop for the iPhone and iPad but, like most hobbies (or businesses!), it will cost some money. Of course, once you get good at it and build an awesome app, you’ll have the potential to make that money back many times.

Xcode

The first order of business is to download and install Xcode and the iOS SDK.

What’s ahead: An overview

The iOS Apprentice is spread across four apps, and moves from beginning to intermediate topics. You’ll build each app from start to finish, from scratch! Let’s take a look at what’s ahead.

Building apps with SwiftUI

You’ll build the first two apps using the newly-announced SwiftUI framework. Announced in 2019 at Apple’s WWDC (World Wide Developer Conference), it’s a completely different way for developers to design apps. Since it looks like SwiftUI will eventually become the preferred way to build apps, we decided to introduce it to you with your first two apps.

App 1: Bullseye

You’ll start by building a game called Bullseye. You’ll learn how to use Xcode, Swift and SwiftUI in a way that’s easy to understand.

App 2: Checklist

For your next trick, you’ll create your own to-do list app. You’ll learn more about SwiftUI, the fundamental design patterns that all iOS apps use, data structures, sharing information between objects, and saving the user’s information. Now you’re making apps for real!

Building apps with UIKit

From the very first iPhone OS and all the way up to iOS 12, iOS apps were written using Apple’s original user interface framework, UIKit. With over a decade’s worth of UIKit-based code, documentation and tutorials, today’s iOS developers can’t rely on SwiftUI alone – they’ll have to know both user interface frameworks. That’s why you’ll build the next two apps with UIKit.

App 3: MyLocations

For your third app, you’ll develop a location-aware app that lets you keep a list of spots that you find interesting. In the process, you’ll learn about UIKit, Core Location, Core Data, Map Kit and much more!

App 4: StoreSearch

Mobile apps often need to talk to web services, and that’s what you’ll do in your final app. You’ll make a stylish app that lets you search for products on the iTunes store using HTTP requests and JSON.

The language of the computer

The iPhone may pretend that it’s a phone, but it’s really a pretty advanced handheld computer that happens to have the ability to make phone calls. Like any computer, the iPhone works with ones and zeros. When you write software to run on the iPhone, you somehow have to translate the ideas in your head into those ones and zeros so that the computer can understand you.

func handleMusicEvent(command: Int, noteNumber: Int, velocity: Int) {

  if command == NoteOn && velocity != 0 {
    playNote(noteNumber + transpose, velocityCurve[velocity] / 127)

  } else if command == NoteOff || 
           (command == NoteOn && velocity == 0) {
    stopNote(noteNumber + transpose, velocityCurve[velocity] / 127)

  } else if command == ControlChange {
    if noteNumber == 64 {
      damperPedal(velocity)
    }
  }
}
Have a technical question? Want to report a bug? You can ask questions and report bugs to the book authors in our official book forum here.
© 2024 Kodeco Inc.

You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now