Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
iOS 10 Programming for Beginners
iOS 10 Programming for Beginners

iOS 10 Programming for Beginners: Explore the latest iOS 10 and Swift 3 features

Arrow left icon
Profile Icon Craig Clayton
Arrow right icon
$19.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5 (2 Ratings)
Paperback Dec 2016 678 pages 1st Edition
eBook
$29.99 $43.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m
Arrow left icon
Profile Icon Craig Clayton
Arrow right icon
$19.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5 (2 Ratings)
Paperback Dec 2016 678 pages 1st Edition
eBook
$29.99 $43.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m
eBook
$29.99 $43.99
Paperback
$54.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

iOS 10 Programming for Beginners

Chapter 1. Getting Familiar with Xcode

So, you want to get into iOS development? I was in your shoes on January 27th, 2010, when Apple first announced the iPad. Literally as soon as the conference was over, I knew that I wanted to learn how to create apps for the iPad. I signed up on the Apple Developer website and paid my $99 annual fee. But then, I realized that I did not know where to begin. A large variety of instructional books or videos did not exist, especially since the iPad had not yet been released. I had previous programming experience—however, I had no idea how to write Objective-C (the original programming language for iOS). Therefore, I had to teach myself the basics. In this book, we will learn together what it takes to become an iOS developer.

If you are new to programming, take your time. You should understand the lessons in one chapter before moving on to the next chapter. These important skills will set you up with a solid foundation in iOS development. If you have previous programming experience, you should still review the earlier chapters, as they will be a refresher for you.

Throughout this book, we will work in Xcode, specifically Xcode 8 (and Swift 3, which we will tackle later in the book). Xcode is known as an Integrated Development Environment (IDE). Using Xcode gives us everything we will need in order to build apps for iOS, tvOS, macOS (formerly, OS X), and watchOS. In this chapter, we will explore Xcode in order to help you get more comfortable using it. If you are not on Xcode 8, make sure to update Xcode, as the code in this book will not run properly otherwise.

Our focus in this book will be to create a universal iOS app (an app for both the iPhone and iPad). The best way to do this is to create a project to familiarize yourself with where everything is and how to find what you need. So, let's first download and install Xcode.

Getting started

In order to download Xcode, launch the App Store on your Mac and then type Xcode into the search bar in the upper-right corner:

Getting started

Next, click on INSTALL:

Getting started

Once installed, launch Xcode, and you should see the following Welcome to Xcode screen:

Getting started

If this is the first time you have launched Xcode, then you will see No Recent Projects in the right panel. If you have previously created projects, then you will see those listed to the right. To get started, we are going to click on Create a new Xcode project in the left panel of the welcome screen. This will take us to the new project screen:

Getting started

Across the top of this screen, you can select one of the following items—iOS, watchOS, tvOS, macOS, and Cross-Platform. Since we are creating apps for iOS, make sure that you have iOS selected. Then, select Single View Application and click on Next. Now, you will see an options screen for a new project:

Getting started

This option screen has the following eight items to complete or choose:

  1. Product Name: The product name is your app. We are going to set ours as ExploringXcode.
  2. Team: The team is connected to your Apple account. We are going to ignore this for now, because it is not needed for this chapter. If you have a team set up, just leave it as is. We will cover this in greater detail later in the book.
  3. Organization Name: You can set the organization name to your company name or just your name.
  4. Organizer Identifier: You will set the organizer identifier to be your domain name in reverse. For example, my website URL is cocoa.academy, and therefore, my identifier is academy.cocoa. Since URLs are unique, it will ensure that no one else will have your identifier. If you do not have a domain, then just use your first and last name for now. You will eventually have to purchase a domain if you would like to submit your app to the Apple store.
  5. Bundle Identifier: When you create a new project, Apple will combine your Product Name with your Organizer Identifier to create your unique bundle identifier. So even if 10,000 people create this project, each person will have a different bundle identifier.
  6. Language: Make sure your language is set to Swift.
  7. Devices: We are going to set this as Universal (iPhone and iPad).
  8. Checkboxes: You can uncheck Use Core Data, Include Unit Tests, and Include UI Tests, as these are things we will not be using in this chapter.

Now, select Next, and Xcode will prompt us to save our project. I have a dedicated folder for all my projects, but you can save it on your desktop for easy access.

The Xcode interface

Your project is now open, and it is time for us to get familiar with all of the panels. If this is your first time in Xcode, then it probably will be a bit overwhelming for you. Therefore, we will break it down into five parts:

  • NAVIGATOR PANEL
  • STANDARD EDITOR
  • UTILITIES PANEL
  • DEBUG PANEL
  • TOOLBAR
  • WINDOW PANE CONTROLS
The Xcode interface

Navigator panel

The primary use for the Navigator panel is to add new files and/or select existing files. The other icons are used from time to time, which we will cover as we need them.

Standard editor

The Standard editor is a single panel view used to edit files. The Standard editor area is the primary area in which you will work. In this area, we can view Storyboard files, see our Swift files, or view our project settings.

Utilities panel

The Utilities panel can be a bit confusing when you first use Xcode, because this menu changes based on what you have selected in the Standard editor. When we start building an app, we will dig deeper into this. For now, just know that the Utilities panel is made up of the inspector pane at the top and the library pane at the bottom. The inspector pane allows you to change attributes or properties of things you put in your Storyboard—the library pane allows you to insert objects, image assets, and code snippets into your app.

Debug panel

The Debug panel will allow us to see log messages from our app. You will become very familiar with this panel by the time you finish this book. The Debug panel is one of the greatest tools to get feedback on what your app is doing or not doing.

Toolbar

Next, we look at the Toolbar:

Toolbar

First, we have a Play button, which is how we launch our app (or use Cmd + R). Next, you will see a Stop button, which will not be active until you run your app. This Stop button (or Cmd + .) is used to stop your app from running. To the right of the Stop button, you will see your target (your project name) along with the current simulator selected. If you click on your project name, you will see a screen similar to this:

Toolbar

This drop-down menu, which we will call the device and Simulator drop-down menu, allows you to change your simulator type. For the purposes of our project, select iPhone 7 Plus as your simulator and then click on the play icon (or use Cmd + R) to run your app. Your app will be blank and most likely will not fit the entire screen (unless you are on a large screen).

In order to see the entire screen, you can scroll right and left—however, doing this gets harder once you have elements in your app. So, an alternative to scrolling is to resize your app to fit the screen. We can do this by going to your Simulator menu and navigating to Window | Scale:

Toolbar

Here, you will be able to scale from 100% to 75%, 50%, 33%, or 25% (select whichever percentage allows the app to best fit your screen size).

Now, let's return to Xcode and select the Stop button (or use Cmd + .).

Tip

If you use the keyboard shortcut, make sure Xcode is in focus; otherwise, this shortcut will not work. I work on a 15-inch Macbook Pro Retina—therefore, when I am working on an app, I will use the iPhone 6 or iPad Air 2 simulator in landscape. They both fit nicely on my screen without having to resize either.

In addition to the simulator, there is a Build Only Device as well as a Device section, both at the top of the device and Simulator drop-down menu that was shown earlier in this chapter. Note that, for our purposes, you will only need a Simulator while we are building the app—however, you can add an iOS device if you would like (see under iOS Device).

Generic iOS Device

The Generic iOS Device, under the Build Only Device section of the device and simulator drop-down menu, is used for when you need to archive your app, which means that you are preparing your app for submission to Apple (either to the App Store or to Test Flight). If you try to select Generic iOS Device now and run the app, you will get the following message:

Generic iOS Device

Therefore, change Generic iOS Device to an actual Simulator, and then you will be able to continue.

iOS device

If you do not have a device connected to the computer, you will see No devices connected . . . under the Device section of the device and simulator drop-down menu.

As noted earlier, when we start building the Let's Eat app, you will have the option of using the Simulator or connecting a device to Xcode. Using a device is slower—however, the simulator will not perform the same as a device will.

In the past you, you needed to have a paid account to build your app on a device. Now, you do not need a developer account in order to run the app on your device. Note that if you decide to connect your device instead of using a simulator, you will need iOS 10 installed on it. The following steps are only for those who do not want to pay for the Apple Developer Program at this time:

  1. Connect your iOS device via USB.
  2. In the drop-down menu, select your device (here, Craig's iPhone):
    iOS device
  3. Wait for Xcode 8 to finish indexing and processing. This may take a bit of time. Once complete, the status will say Ready.
  4. Run the project by hitting the Play button (or use Cmd + R).

    You will get two errors that state the following:

    • Signing for ExploringXcode requires a development team. Select a development team in the project editor.
    • Code signing is required for product type Application in SDK iOS 10.0.

    Ignore the specifics of these errors as they basically indicate that we need to create an account and add our device to that account.

  5. Now, in the Standard editor, you will see under Signing that you need to add an account:
    iOS device
  6. Click on Add Account. If a Sign in to Xcode with your Apple ID dialog box does not pop up, inside of the Accounts screen on the bottom left, click on the + and select Add Apple ID:

    iOS device
  7. Then, you will click on Create Apple ID. You will be asked to enter your birth date, name, e-mail, and password, along with security questions. Make sure that you verify your e-mail before you answer the security questions; otherwise, you will have to come back to this screen and add Apple ID again.
  8. Once you have finished all the steps, you will see your account:
    iOS device

If you already have an account, then, instead of seeing Add Account, you will see a drop-down menu with your account listed. If your device is not connected to this account, you might see a message asking if you would like to add your device to your account.

You will not need to use a device for the majority of this book—however, depending on the type of Macbook you have, you might need to use a device.

Before we get to the right side of the Toolbar, select the Main.storyboard file in your Navigator panel. This file is used to do all of your visual setup for your entire app. We will cover this in detail later in the book. After you select the file, you should see the following:

iOS device

Window Pane Controls

The following screenshot shows Window Pane Controls:

Window Pane Controls

Tip

For better quality of images, download the Graphics bundle from : https://www.packtpub.com/sites/default/files/downloads/iOS10ProgrammingforBeginners_ColoredImages.pdf

Moving onto the Window Pane Controls, you will see two groups of icons. The first group is called the Editor Mode, and the second group is called the View. Let's look at the functions of the Editor Mode icons:

Editor Mode icons

Function

Window Pane Controls

This icon controls the Standard editor (which is the center panel in the earlier screenshot of the Main.storyboard file in the Navigator panel).

Window Pane Controls

This icon splits the Standard editor into two panels, where you will see the ViewController.swift file on the right. We will use this split screen throughout the book.

Window Pane Controls

This icon is the Version editor. We will not address the Version editor in this book, since it is a more advanced feature.

At this point, you might be thinking that there are way too many panels open, and I would agree with you. This is where the last group of View icons in the Toolbar comes in handy.

Let's look at these icons and their functions in the following table:

View Mode icons

Functions

Window Pane Controls

This icon will toggle (hide or show) the Navigator panel (or use Cmd + 0).

Window Pane Controls

This icon will toggle (hide or show) the Debug panel (or use Cmd + Shift + Y).

Window Pane Controls

This icon will toggle (hide or show) the Utilities panel (or use Cmd + Alt + 0).

Summary

Congratulations! You have finished exploring the basics of Xcode. When we start building our app, we will cover the more important parts of Xcode in depth. It is now time to start learning Swift 3.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Use Swift 3 and latest iOS 10 features to build awesome apps for iPhone and iPad
  • Explore and use a wide range of Apple development tools to become a confident iOS developer
  • From prototype to App Store—find out how to build an app from start to finish!

Description

You want to build iOS applications for iPhone and iPad—but where do you start? Forget sifting through tutorials and blog posts, this is a direct route into iOS development, taking you through the basics and showing you how to put the principles into practice. With every update, iOS has become more and more developer-friendly, so take advantage of it and begin building applications that might just take the App Store by storm! Whether you’re an experienced programmer or a complete novice, this book guides you through every facet of iOS development. From Xcode and Swift—the building blocks of modern Apple development—and Playgrounds for beginners, one of the most popular features of the iOS development experience, you’ll quickly gain a solid foundation to begin venturing deeper into your development journey. For the experienced programmer, jump right in and learn the latest iOS 10 features. You’ll also learn the core elements of iOS design, from tables to tab bars, as well as more advanced topics such as gestures and animations that can give your app the edge. Find out how to manage databases, as well as integrating standard elements such as photos, GPS into your app. With further guidance on beta testing with TestFlight, you’ll quickly learn everything you need to get your project on the App Store!

Who is this book for?

This book is for beginners who want to be able to create iOS applications. If you have some programming experience, this book is a great way to get a full understanding of how to create an iOS application from scratch and submit it to the App Store. You do not need any knowledge of Swift or any prior programming experience.

What you will learn

  • Get to grips with Swift 3 and Xcode, the building blocks of Apple development
  • Get to know the fundamentals of Swift, including variables, constants, and control flow
  • Discover the distinctive design principles that define the iOS user experience
  • See how to prototype your app with Swift's Playgrounds feature
  • Build a responsive UI that looks great on a range of devices
  • Find out how to use CoreLocation to add location services to your app
  • Add push notifications to your app
  • Make your app able to be used on both iPhone and iPad

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Dec 27, 2016
Length: 678 pages
Edition : 1st
Language : English
ISBN-13 : 9781786464507
Category :
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Dec 27, 2016
Length: 678 pages
Edition : 1st
Language : English
ISBN-13 : 9781786464507
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 103.98
iOS Programming Cookbook
$48.99
iOS 10 Programming for Beginners
$54.99
Total $ 103.98 Stars icon

Table of Contents

19 Chapters
1. Getting Familiar with Xcode Chevron down icon Chevron up icon
2. Building a Foundation with Swift Chevron down icon Chevron up icon
3. Digging Deeper Chevron down icon Chevron up icon
4. Digging into Collections Chevron down icon Chevron up icon
5. Starting the UI Setup Chevron down icon Chevron up icon
6. Setting Up UI Chevron down icon Chevron up icon
7. Getting Started with the Grid Chevron down icon Chevron up icon
8. Getting Started with the List Chevron down icon Chevron up icon
9. Working More with Lists Chevron down icon Chevron up icon
10. Where Are We? Chevron down icon Chevron up icon
11. Where's My Data? Chevron down icon Chevron up icon
12. Foodie Reviews Chevron down icon Chevron up icon
13. Saving Reviews Chevron down icon Chevron up icon
14. Universal Chevron down icon Chevron up icon
15. iMessages Chevron down icon Chevron up icon
16. Notifications Chevron down icon Chevron up icon
17. Just a Peek Chevron down icon Chevron up icon
18. Beta and Store Submission Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.5
(2 Ratings)
5 star 50%
4 star 50%
3 star 0%
2 star 0%
1 star 0%
Amazon Customer Nov 07, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Amazing help. Well written.
Amazon Verified review Amazon
Dimitri Shvorob Aug 13, 2017
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Given the immense popularity of iOS programming, I am surprised by how limited the options for people wishing to learn it are. Having now seen eight iOS titles - see my other reviews - I can only recommend two titles as possible choices: "iOS Programming" by Keur and Hillegass, and this book. The Keur-Hillegass book seems to be the market leader, but I actually prefer Clayton's. "iOS 10 Programming for Beginners" covers less ground, but its writing shows more care, and its slow-and-steady approach is appropriate for a beginner's book. You will still need Keur-Hillegass, but I would suggest starting with this book.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.