Book description
The professional programmer’s Deitel® guide to iPhone® and iPad® app development using iOS® 8, Swift™, Xcode® 6, and Cocoa Touch®
Billions of apps have been downloaded from Apple’s App Store! This book gives you everything you’ll need to start developing great iOS 8 apps quickly using Swift–Apple’s programming language of the future. You’ll also learn what makes a great app and how to publish your apps in the App Store. The book uses an app-driven approach–each new technology is discussed in the context of seven fully tested iOS 8 apps, complete with syntax shading, code highlighting, code walkthroughs and sample outputs. Apps you’ll develop include:
Welcome App
Cannon Game
Tip Calculator
Doodlz
Twitter® Searches
Address Book
Flag Quiz
Practical, Example-Rich Coverage of:
iOS® 8, XCode® 6, Swift™
Object-Oriented Programming with Swift™ and Cocoa Touch®
UI Design, Storyboards, Auto Layout, Outlets, Outlet Collections, Actions
View Controllers, Views, View Animations
Event Handling, Multi-Touch
Single View, Master-Detail, Game Templates
Accessibility, Internationalization
Core Data Database Access
User Defaults, iCloud Key—Value Storage
Social Framework Sharing
SpriteKit Game Programming: Animation, Graphics, Physics, Collision Detection
Accelerometer and Motion Event Handling
Grand Central Dispatch
App Store, Pricing, Monetization and more.
IMPORTANT NOTE ABOUT XCODE AND SWIFT: With Xcode 6.3 and Swift 1.2, Apple introduced several changes in Swift that affect the book's source code. Please visit www.deitel.com/books/iOS8FP1 for updated source code. The changes do not affect Xcode 6.2 users. You can download Xcode 6.2 from developer.apple.com/downloads/index.action (you’ll have to log in with your Apple developer account to see the list of downloads).
Visit www.deitel.com
Download code examples
For information on Deitel’s Dive Into® Series programming training courses delivered at organizations worldwide visit www.deitel.com/training or write to deitel@deitel.com
Join the Deitel social networking communities on Facebook® at facebook.com/DeitelFan, Twitter® at @deitel, Google+™ at google.com/+DeitelFan, LinkedIn® at bit.ly/DeitelLinkedIn, YouTube™ at youtube.com/user/DeitelTV and subscribe to the Deitel® Buzz Online e-mail newsletter at www.deitel.com/newsletter/subscribe.html
About This Book
Sales of iOS devices and app downloads have been explosive. The first-generation iPhone sold 6.1 million units in its initial five quarters of availability (bit.ly/iPhoneGen1l). The iPhone 6 and iPhone 6 Plus, released in September 2014, sold over 10 million combined in their first weekend of availability (bit.ly/FirstiPhone6Weekend). iPad sales are equally impressive. The first generation iPad, launched in April 2010, sold 3 million units in its first 80 days of availability (bit.ly/iPadGen1). In just the first quarter of 2014, Apple sold a record 26 million iPads (bit.ly/iPad2014Q1). At the time of this writing, there were over 1.2 million apps in the App Store (bit.ly/iOSApps2014) and more than 75 billion apps have been downloaded!
This book presents leading-edge computing technologies for professional software developers. At the heart of the book is the Deitel “app-driven approach”– a variant of Deitel’s live-code approach–concepts are presented in the context of complete working iOS apps, rather than using code snippets. The introduction and app test drives at the beginning of each chapter show one or more sample executions. The book’s source code is available at: www.deitel.com/books/iOS8FP1.
You’ll quickly learn everything you need to start building iOS 8 apps–beginning with a test-drive of the Tip Calculator app in Chapter 1, then building your first apps in Chapter 2 with visual programming and in Chapter 3 with Swift. By the time you reach Chapter 9, you’ll be ready to create your own apps for submission to the App Store. We’ll overview the submission process, including uploading your apps, deciding whether to sell your apps or offer them for free, and marketing them using in-app advertising, social media, Internet public relations and more.
Table of contents
- About This eBook
- Title Page
- Copyright Page
- Deitel® Series Page
- Dedication Page
- Contents
-
Preface
- Explosive Growth of the iPhone and iPad Is Creating Opportunity for Developers
- SafariBooksOnline e-Book and LiveLessons Videos
- Copyright Notice and Code License
- Intended Audience
- Academic Bundle iOS® 8 for Programmers and Swift™ for Programmers
- Key Features of iOS® 8 for Programmers: An App-Driven Approach with Swift™, Volume 1, 3/e
- Features
- iOS® 8 for Programmers: An App-Driven Approach with Swift™, Volume 2
- iOS® 8 Fundamentals LiveLessons Video Training Products
- Acknowledgments
- About the Authors
- About Deitel® & Associates, Inc.
-
Before You Begin
- Font and Naming Conventions
- Conventions for Referencing Menu Items in a Menu
- Software Used in this Book
- Becoming a Registered Apple Developer
- Fee-Based Developer Programs
- Adding Your Paid iOS Developer Program Account to Xcode
- Obtaining the Code Examples
- Xcode Projects
- Configuring Xcode to Display Line Numbers
- Configuring Xcode’s Code Indentation Options
-
1. Introduction to iOS 8 App Development and Swift
- 1.1 Introduction
- 1.2 iPhone and iPad Sales Data
- 1.3 Gestures
- 1.4 Sensors
- 1.5 Accessibility
- 1.6 iPhone 6 and iPhone 6 Plus
- 1.7 iOS Operating System History and Features
- 1.8 iOS 8
- 1.9 Apple Watch
- 1.10 App Store
- 1.11 Objective-C
- 1.12 Swift: Apple’s Programming Language of the Future
- 1.13 Can I Use Swift Exclusively?
- 1.14 Cocoa Touch® iOS Frameworks
- 1.15 Xcode 6® Integrated Development Environment
- 1.16 Object Oriented-Programming Review
- 1.17 Test-Driving the Tip Calculator App in the iPhone and iPad Simulators
- 1.18 What Makes a Great App?
- 1.19 iOS Security
- 1.20 iOS Publications and Forums
- 1.21 Wrap-Up
-
2. Welcome App
- 2.1 Introduction
- 2.2 Technologies Overview
- 2.3 Creating a Universal App Project with Xcode
- 2.4 Xcode Workspace Window
-
2.5 Storyboarding the Welcome App’s UI
- 2.5.1 Configuring the App for Portrait and Landscape Orientations
- 2.5.2 Providing an App Icon
- 2.5.3 Creating an Image Set for the App’s Image
- 2.5.4 Overview of the Storyboard and the Xcode Utilities Area
- 2.5.5 Adding an Image View to the UI
- 2.5.6 Using Inspectors to Configure the Image View
- 2.5.7 Adding and Configuring the Label
- 2.5.8 Using Auto Layout to Support Different Screen Sizes and Orientations
- 2.6 Running the Welcome App
- 2.7 Making Your App Accessible
- 2.8 Internationalizing Your App
- 2.9 Wrap-Up
-
3. Tip Calculator App
- 3.1 Introduction
-
3.2 Technologies Overview
- 3.2.1 Swift Programming
- 3.2.2 Swift Apps and the Cocoa Touch® Frameworks
- 3.2.3 Using the UIKit and Foundation Frameworks in Swift Code
- 3.2.4 Creating Labels, a Text Field and a Slider with Interface Builder
- 3.2.5 View Controllers
- 3.2.6 Linking UI Components to Your Swift Code
- 3.2.7 Performing Tasks After a View Loads
- 3.2.8 Financial Calculations with NSDecimalNumber
- 3.2.9 Formatting Numbers as Locale-Specific Currency and Percentage Strings
- 3.2.10 Bridging Between Swift and Objective-C Types
- 3.2.11 Swift Operator Overloading
- 3.2.12 Variable Initialization and Swift Optional Types
- 3.2.13 Value Types vs. Reference Types
- 3.2.14 Code Completion in the Source-Code Editor
- 3.3 Building the App’s UI
- 3.4 Creating Outlets with Interface Builder
- 3.5 Creating Actions with Interface Builder
-
3.6 Class ViewController
- 3.6.1 import Declarations
- 3.6.2 ViewController Class Definition
- 3.6.3 ViewController’s @IBOutlet Properties
- 3.6.4 Other ViewController Properties
- 3.6.5 Overridden UIViewController method viewDidLoad
- 3.6.6 ViewController Action Method calculateTip
- 3.6.7 Global Utility Functions Defined in ViewController.swift
- 3.7 Wrap-Up
-
4. Twitter® Searches App
- 4.1 Introduction
- 4.2 Test-Driving the App
-
4.3 Technologies Overview
- 4.3.1 Master-Detail Application Template
- 4.3.2 Web View—Displaying Web Content in an App
- 4.3.3 Swift: Array and Dictionary Collections
- 4.3.4 NSUserDefaults—Local Key–Value Pair Storage for App Settings
- 4.3.5 iCloud Key–Value Pair Storage with NSUbiquitousKeyValue-Store
- 4.3.6 Social Framework
- 4.3.7 Model-View-Controller (MVC) Design Pattern
- 4.3.8 Swift: Conforming to Protocols
- 4.3.9 Swift: Exposing Methods to Cocoa Touch Libraries
- 4.3.10 UIAlertController for Alert Dialogs
- 4.3.11 UILongPressGestureRecognizer
- 4.3.12 iOS Design Patterns Used in This App
- 4.3.13 Swift: External Parameter Names
- 4.3.14 Swift: Closures
- 4.4 Building the App’s UI
-
4.5 Class Model
- 4.5.1 ModelDelegate Protocol
- 4.5.2 Model Properties
- 4.5.3 Model Initializer and synchronize Method
- 4.5.4 Methods tagAtIndex, queryForTag and queryForTagAt-Index, and Property count
- 4.5.5 Method deleteSearchAtIndex
- 4.5.6 Method moveTagAtIndex
- 4.5.7 Method updateUserDefaults
- 4.5.8 Method updateSearches
- 4.5.9 Method performUpdates
- 4.5.10 Method saveQuery
-
4.6 Class MasterViewController
- 4.6.1 MasterViewController Properties and modelDataChanged Method
- 4.6.2 Method awakeFromNib
- 4.6.3 Overridden UIViewController Method viewDidLoad and Method addButtonPressed
- 4.6.4 Methods tableViewCellLongPressed and displayLong-PressOptions
- 4.6.5 Method displayAddEditSearchAlert
- 4.6.6 Method shareSearch
- 4.6.7 Overridden UIViewController Method prepareForSegue
- 4.6.8 Method urlEncodeString
- 4.6.9 UITableViewDataSource Callback Methods
- 4.7 Class DetailViewController
- 4.8 Wrap-Up
-
5. Flag Quiz App
- 5.1 Introduction
- 5.2 Test-Driving the Flag Quiz App
-
5.3 Technologies Overview
- 5.3.1 Designing a Storyboard from Scratch
- 5.3.2 UINavigationController
- 5.3.3 Storyboard Segues
- 5.3.4 UISegmentedControls
- 5.3.5 UISwitches
- 5.3.6 Outlet Collections
- 5.3.7 Using the App’s Main NSBundle to Get a List of Image Filenames
- 5.3.8 Using Grand Central Dispatch to Perform a Task in the Future
- 5.3.9 Applying an Animation to a UIView
- 5.3.10 Darwin Module—Using Predefined C Functions
- 5.3.11 Random-Number Generation
- 5.3.12 Swift Features Introduced
-
5.4 Building the GUI
- 5.4.1 Creating the Project
- 5.4.2 Designing the Storyboard
- 5.4.3 Configuring the View Controller Classes
- 5.4.4 Creating the UI for the QuizViewController
- 5.4.5 Auto Layout Settings for the QuizViewController UI
- 5.4.6 QuizViewController Outlets and Actions
- 5.4.7 Creating the UI for the SettingsViewController
- 5.4.8 SettingsViewController Outlets and Actions
- 5.4.9 Creating Class Model
- 5.4.10 Adding the Flag Images to the App
- 5.5 Model Class
-
5.6 QuizViewController Class
- 5.6.1 Properties
- 5.6.2 Overridden UIViewController Method viewDidLoad, and Methods settingsChanged and resetQuiz
- 5.6.3 Methods nextQuestion and countryFromFilename
- 5.6.4 Method submitGuess
- 5.6.5 Method shakeFlag
- 5.6.6 Method displayQuizResults
- 5.6.7 Overridden UIViewController Method prepareForSegue
- 5.6.8 Array Extension shuffle
- 5.7 SettingsViewController Class
- 5.8 Wrap-Up
-
6. Cannon Game App
- 6.1 Introduction
- 6.2 Test-Driving the Cannon Game App
-
6.3 Technologies Overview
- 6.3.1 Xcode Game Template and SpriteKit
- 6.3.2 Adding Sound with the AVFoundation Framework and AVAudioPlayer
- 6.3.3 SpriteKit Framework Classes
- 6.3.4 SpriteKit Game Loop and Animation Frames
- 6.3.5 Physics
- 6.3.6 Collision Detection and the SKPhysicsContactDelegate Protocol
- 6.3.7 CGGeometry Structures and Functions
- 6.3.8 Overriding UIResponder Method touchesBegan
- 6.3.9 Game-Element Sizes and Velocities Based on Screen Size
- 6.3.10 Swift Features
- 6.3.11 NSLocalizedString
- 6.4 Creating the Project and Classes
- 6.5 Class GameViewController
- 6.6 Class Blocker
- 6.7 Class Target
- 6.8 Class Cannon
-
6.9 Class GameScene
- 6.9.1 CollisionCategory struct
- 6.9.2 GameScene Class Definition and Properties
- 6.9.3 Overridden SKScene Method didMoveToView
- 6.9.4 Method createLabels
- 6.9.5 SKPhysicsContactDelegate Method didBeginContact and Supporting Methods
- 6.9.6 Overridden UIResponder Method touchesBegan
- 6.9.7 Overridden SKScene Method update and Method gameOver
- 6.10 Class GameOverScene
- 6.11 Programmatic Internationalization
- 6.12 Wrap-Up
-
7. Doodlz App
- 7.1 Introduction
-
7.2 Test-Driving the Doodlz App
- Opening the Completed Application
- Understanding the App’s Options
- Changing the Drawing Color to Red
- Changing the Stroke Width
- Drawing the Flower Petals
- Changing the Brush Color to Dark Green
- Changing the Stroke Width and Drawing the Stem and Leaves
- Changing the Brush Color to a Semitransparent Blue
- Actions You Can Perform with Your Image
- Saving and Printing APIs
- Shake to Erase
- Simulating Multi-Touch
- 7.3 Technologies Overview
- 7.4 Building the App’s UI and Adding Its Custom Classes
-
7.5 ViewController Class
- 7.5.1 ViewController Class Definition, Property and Delegate Methods
- 7.5.2 Overridden UIViewController Method prepareForSeque
- 7.5.3 ViewController Methods undoButtonPressed, clearButtonPressed and displayEraseDialog
- 7.5.4 Overridden UIResponder Method motionEnded
- 7.5.5 ViewController Method actionButtonPressed
- 7.6 Squiggle Class
- 7.7 DoodleView Class
- 7.8 ColorViewController Class
- 7.9 StrokeViewController Class
- 7.10 Wrap-Up
-
8. Address Book App
- 8.1 Introduction
- 8.2 Test-Driving the Address Book App
-
8.3 Technologies Overview
- 8.3.1 Enabling Core Data Support
- 8.3.2 Data Model and Xcode’s Data Model Editor
- 8.3.3 Core Data Framework Classes and Protocols
- 8.3.4 UITableViewController Cell Styles
- 8.3.5 UITableViewController with Static Cells
- 8.3.6 Listening for Keyboard Show and Hide Notifications
- 8.3.7 Programmatically Scrolling a UITableView
- 8.3.8 UITextFieldDelegate Methods
- 8.4 Creating the Project and Configuring the Data Model
- 8.5 Building the GUI
-
8.6 MasterViewController Class
- 8.6.1 MasterViewController Class, Properties and awakeFromNib Method
- 8.6.2 Overridden UIViewController Method viewWillAppear and Method displayFirstContactOrInstructions
- 8.6.3 Overridden UIViewController Method viewDidLoad
- 8.6.4 Overridden UIViewController Method prepareForSegue
- 8.6.5 AddEditTableViewControllerDelegate Method didSaveContact
- 8.6.6 DetailViewControllerDelegate Method didEditContact
- 8.6.7 Method displayError
- 8.6.8 UITableViewDelegate Methods
- 8.6.9 Autogenerated NSFetchedResultsController and NSFetchedResultsControllerDelegate Methods
- 8.7 DetailViewController Class
-
8.8 AddEditTableViewController Class
- 8.8.1 AddEditTableViewControllerDelegate Protocol
- 8.8.2 AddEditTableViewController Properties
- 8.8.3 Overridden UIViewController Methods viewWillAppear and viewWillDisappear
- 8.8.4 Overridden UIViewController Method viewDidLoad
- 8.8.5 Methods keyboardWillShow and keyboardWillHide
- 8.8.6 UITextFieldDelegate Method textFieldShouldReturn
- 8.8.7 @IBAction saveButtonPressed
- 8.9 AppDelegate Class
- 8.10 Wrap-Up
-
9. App Store and App Business Issues
- 9.1 Introduction
- 9.2 iOS Developer Program: Setting Up Your Profile for Testing and Submitting Apps
- 9.3 iOS Human Interface Guidelines
- 9.4 Preparing Your App for Submission through iTunes Connect
- 9.5 Pricing Your App: Fee or Free
- 9.6 Monetizing Apps
- 9.7 Managing Your Apps with iTunes Connect
- 9.8 Information You’ll Need for iTunes Connect
- 9.9 iTunes Connect Developer Guide: Steps for Submitting Your App to Apple
- 9.10 Marketing Your App
- 9.11 Other Popular Mobile App Platforms
- 9.12 Tools for Multiple-Platform App Development
- 9.13 Wrap-Up
- Index
- Code Snippets
Product information
- Title: iOS 8 for Programmers: An App-Driven Approach with Swift, 3rd Edition
- Author(s):
- Release date: December 2014
- Publisher(s): Pearson
- ISBN: 9780133965315
You might also like
video
iOS 8 App Development with Swift
In these two LiveLessons videos, Paul Deitel presents everything you need to know to become an …
video
iOS 8 App Development I and II
Overview The professional programmer’s Deitel® video guide to iPhone® and iPad®app development using iOS® 8, Swift™, …
book
Programming iOS 13
If you’re grounded in the basics of Swift, Xcode, and the Cocoa framework, this book provides …
book
iOS Programming Cookbook
Over 50 exciting and powerful recipes to help you unearth the promise of iOS programming About …