Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
About This eBook
Title Page
Copyright Page
Deitel® Series Page
Deitel® Developer Series
How To Program Series
Simply Series
CourseSmart Web Books
LiveLessons Video Learning Products
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
Ordering the Books and Supplements Separately
Instructor Supplements
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
Pearson Education Team
Reviewers
Keeping in Touch with the Authors
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
A Note Regarding the Xcode 6 Toolbar Icons
Becoming a Registered Apple Developer
Fee-Based Developer Programs
iOS Developer Program
iOS Developer Enterprise Program
iOS Developer University Program
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
App-Driven Approach
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.7.1 iPhone Operating System
1.7.2 iPhone OS 2: Introducing Third-Party Apps and the App Store
1.7.3 iPhone OS 3
1.7.4 iOS 4
1.7.5 iOS 5
1.7.6 iOS 6
1.7.7 iOS 7
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.12.1 Key Features
1.12.2 Performance
1.12.3 Error Prevention
1.12.4 Swift Standard Library
1.12.5 Swift Apps and the Cocoa® and Cocoa Touch® Frameworks
1.12.6 Swift and Objective-C Interoperability
1.12.7 Other Apple Swift Resources
1.13 Can I Use Swift Exclusively?
1.13.1 Objective-C Programmers Who Are Developing New iOS Apps in Swift
1.13.2 Objective-C Programmers Who Are Enhancing Existing iOS Apps with Swift
1.13.3 Java, C++ and C# Programmers Who Are New to iOS App Development
1.13.4 Rapid Evolution Expected
1.13.5 Mixing Swift and Objective-C Code
1.14 Cocoa Touch® iOS Frameworks
Foundation Framework
AppKit Framework
UIKit Framework
Other Cocoa Touch Frameworks
Web Services
1.15 Xcode 6® Integrated Development Environment
The iOS Simulator
1.16 Object Oriented-Programming Review
1.16.1 Automobile as an Object
1.16.2 Methods and Classes
1.16.3 Instantiation
1.16.4 Reuse
1.16.5 Messages and Method Calls
1.16.6 Attributes and Properties
1.16.7 Encapsulation and Information Hiding
1.16.8 Inheritance
1.16.9 Protocols
1.16.10 Design Patterns
1.17 Test-Driving the Tip Calculator App in the iPhone and iPad Simulators
Test-Driving the Completed Application Using the iPhone Simulator
Test-Driving the Completed Application Using the iPad Simulator
Test-Drives for the Book’s Apps
1.18 What Makes a Great App?
1.19 iOS Security
Find My iPhone and Remote Wipe
1.20 iOS Publications and Forums
1.21 Wrap-Up
2. Welcome App
2.1 Introduction
2.2 Technologies Overview
2.2.1 Xcode and Interface Builder
2.2.2 Labels and Image Views
2.2.3 Asset Catalogs and Image Sets
2.2.4 Running the App
2.2.5 Accessibility
2.2.6 Internationalization
2.3 Creating a Universal App Project with Xcode
2.3.1 Launching Xcode
2.3.2 Projects and App Templates
2.3.3 Creating and Configuring a Project
2.4 Xcode Workspace Window
2.4.1 Navigator Area
2.4.2 Editor Area
2.4.3 Utilities Area and Inspectors
2.4.4 Debug Area
2.4.5 Xcode Toolbar
2.4.6 Project Navigator
2.4.7 Keyboard Shortcuts
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.6.1 Testing on the iOS Simulator
2.6.2 Testing on a Device (for Paid Apple iOS Developer Program Members Only)
2.7 Making Your App Accessible
2.7.1 Enabling Accessibility for the Image View
2.7.2 Confirming Accessibility Text with the Simulator’s Accessibility Inspector
2.8 Internationalizing Your App
2.8.1 Locking Your UI During Translation
2.8.2 Exporting Your UI’s String Resources
2.8.3 Translating the String Resources
2.8.4 Importing the Translated String Resources
2.8.5 Testing the App in Spanish
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.3.1 Creating the Project
3.3.2 Configuring the Size Classes for Designing a Portrait Orientation iPhone App
3.3.3 Adding the UI Components
3.3.4 Adding the Auto Layout Constraints
3.4 Creating Outlets with Interface Builder
Opening the Assistant Editor
Creating an Outlet
Creating the Other Outlets
3.5 Creating Actions with Interface Builder
Connecting the Slider to Method calculateTip
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
Opening the Completed Application
Running the App
Adding a New Favorite Search
Viewing Twitter Search Results
Editing a Search
Sharing a Search
Deleting a Search and Reordering Searches
Testing the App’s iCloud Capabilities
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.4.1 Creating the Project
4.4.2 Examining the Default Master-Detail Application
4.4.3 Configuring the Master and Detail Views
4.4.4 Creating class Model
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.7.1 Overridden UIViewController Method viewDidLoad
4.7.2 Overridden UIViewController Method viewDidAppear
4.7.3 Overridden UIViewController Method viewWillDisappear
4.7.4 UIWebViewDelegate Protocol Methods
4.8 Wrap-Up
5. Flag Quiz App
5.1 Introduction
5.2 Test-Driving the Flag Quiz App
Opening the Completed Application
Running the App
Configuring the Quiz
Taking the Quiz: Making a Correct Selection
Taking the Quiz: Making an Incorrect Selection
Completing the Quiz
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.5.1 ModelDelegate Protocol
5.5.2 Model Properties
5.5.3 Model Initializer and regionsChanged Method
5.5.4 Model Computed Properties
5.5.5 Model Methods toggleRegion, setNumberOfGuesses and notifyDelegate
5.5.6 Model Method newQuizCountries
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.7.1 Properties
5.7.2 Overridden UIViewController Method viewDidLoad
5.7.3 Event Handlers and Method displayErrorDialog
5.7.4 Overridden UIViewController Method viewWillDisappear
5.8 Wrap-Up
6. Cannon Game App
6.1 Introduction
6.2 Test-Driving the Cannon Game App
Opening the Completed Application
Playing the Game
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
Creating the Project
Landscape Orientation
Hide Status Bar
Add the App Icons to the Asset Catalog
Add the Game’s Sprites (Images) to the Asset Catalog
Adding the Sounds to the App
Add the Game’s Other Classes
6.5 Class GameViewController
6.5.1 Overridden UIViewController Method viewDidLoad
6.5.2 Why Are the AVAudioPlayer Variables Global?
6.5.3 Autogenerated Methods That We Deleted from Class GameViewController
6.6 Class Blocker
6.6.1 BlockerSize enum and Class Blocker’s Properties
6.6.2 Blocker Initializers
6.6.3 Methods startMoving, playHitSound and blockerTimePenalty
6.7 Class Target
6.7.1 TargetSize and TargetColor enums
6.7.2 Class Target Properties
6.7.3 Target Initializers
6.7.4 Methods startMoving, playHitSound and targetTimeBonus
6.8 Class Cannon
6.8.1 Cannon Properties
6.8.2 Cannon Initializers
6.8.3 Method rotateToPointAndFire
6.8.4 Methods fireCannonball and createCannonball
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
Initializer
Initializer
Overridden Method touchesBegan
6.11 Programmatic Internationalization
Localizing Strings in Code with NSLocalizedString
Exporting the String Resources
Translating the String Resources
Importing the Translated String Resources
Testing the App in Spanish
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.3.1 Drawing with UIView Subclasses, Method drawRect, UIBezierPaths and the UIKit Graphics System
7.3.2 Processing Multiple Touch Events
7.3.3 Listening for Motion Events
7.3.4 Rendering the Drawing as a UIImage
7.3.5 Storyboard Loading Initialization
7.4 Building the App’s UI and Adding Its Custom Classes
7.4.1 Creating the Project
7.4.2 Creating the Initial View Controller’s User Interface
7.4.3 Creating the Color View Controller’s User Interface
7.4.4 Creating the Stroke View Controller’s User Interface
7.4.5 Adding the Squiggle Class
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
Overridden UIBezierPath Method stroke
7.7 DoodleView Class
7.7.1 DoodleView Properties
7.7.2 DoodleView Initializer
7.7.3 DoodleView Methods undo and clear
7.7.4 Overridden UIView Method drawRect
7.7.5 Overridden UIResponder Methods for Touch Handling
7.7.6 DoodleView Computed Property image
7.8 ColorViewController Class
7.8.1 ColorViewControllerDelegate Protocol and the Beginning of Class ColorViewController
7.8.2 Overridden UIViewController Method viewDidLoad
7.8.3 ColorViewController Methods colorChanged and done
7.9 StrokeViewController Class
7.9.1 SampleLineView Subclass of UIView
7.9.2 StrokeViewControllerDelegate Protocol and the Beginning of Class StrokeViewController
7.9.3 Overridden UIViewController Method viewDidLoad
7.9.4 StrokeViewController Methods lineWidthChanged and done
7.10 Wrap-Up
8. Address Book App
8.1 Introduction
8.2 Test-Driving the Address Book App
Opening the Completed Application
Adding a Contact
Viewing a Contact
Editing a Contact
Deleting a Contact
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.4.1 Creating the Project
8.4.2 Editing the Data Model
8.4.3 Generating the Contact Subclass of NSManagedObject
8.5 Building the GUI
8.5.1 Customizing the MasterViewController
8.5.2 Customizing the DetailViewController
8.5.3 Adding the AddEditViewController
8.5.4 Adding the InstructionsViewController
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.7.1 DetailViewControllerDelegate Protocol
8.7.2 DetailViewController Properties
8.7.3 Overridden UIViewController Method viewDidLoad and Method displayContact
8.7.4 AddEditTableViewControllerDelegate Method didSaveContact
8.7.5 Overridden UIViewController Method prepareForSegue
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.9.1 UIApplicationDelegate Protocol Method application: didFinishLaunchingWithOptions:
8.9.2 UISplitViewControllerDelegate Protocol Method
8.9.3 Properties and Methods That Support the App’s Core Data Capabilities
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.2.1 Setting Up Your Development Team
9.2.2 Provisioning a Device for App Testing
9.2.3 TestFlight Beta Testing
9.2.4 Creating Explicit App IDs
9.3 iOS Human Interface Guidelines
9.4 Preparing Your App for Submission through iTunes Connect
Keywords
Icons
Launch Images
Screenshot(s)
App Previews
Contract Information
Additional Languages (Optional)
9.5 Pricing Your App: Fee or Free
9.5.1 Paid Apps
9.5.2 Free Apps
9.6 Monetizing Apps
9.6.1 Using In-App Purchase to Sell Virtual Goods
9.6.2 iAd In-App Advertising
9.6.3 App Bundles
9.6.4 Developing Custom Apps for Organizations
9.7 Managing Your Apps with iTunes Connect
Crash Reporting
9.8 Information You’ll Need for iTunes Connect
App Ratings
Pricing
Screenshots of Your App in Action
App Bundle ID
9.9 iTunes Connect Developer Guide: Steps for Submitting Your App to Apple
Logging into iTunes Connect
iTunes Connect Developer Guide Overview
9.10 Marketing Your App
Facebook
Twitter
Viral Video
E-Mail Newsletters
App Reviews
Internet Public Relations
Mobile Advertising Networks
9.11 Other Popular Mobile App Platforms
9.12 Tools for Multiple-Platform App Development
9.13 Wrap-Up
Staying in Contact with Deitel & Associates, Inc.
Index
Code Snippets
← Prev
Back
Next →
← Prev
Back
Next →