Sams Teach Yourself Ios®9 Application Development in 24 Hours

Total Page:16

File Type:pdf, Size:1020Kb

Sams Teach Yourself Ios®9 Application Development in 24 Hours John Ray SamsTeachYourself iOS®9 Application Development in Hours24 800 East 96th Street, Indianapolis, Indiana, 46240 USA Sams Teach Yourself iOS9® Application Development in 24 Hours Editor-in-Chief Copyright © 2016 by Pearson Education, Inc. Greg Wiegand All rights reserved. Printed in the United States of America. This publication is protected by Acquisitions Editor copyright, and permission must be obtained from the publisher prior to any prohibited repro- Laura Norman duction, storage in a retrieval system, or transmission in any form or by any means, electron- ic, mechanical, photocopying, recording, or likewise. For information regarding permissions, Development Editor request forms, and the appropriate contacts within the Pearson Education Global Rights & Keith Cline Permissions Department, please visit www.pearsoned.com/permissions/ . No patent liability is assumed with respect to the use of the information contained herein. Although every pre- Managing Editor caution has been taken in the preparation of this book, the publisher and author assume no Kristy Hart responsibility for errors or omissions. Nor is any liability assumed for damages resulting from Senior Project Editor the use of the information contained herein. Lori Lyons ISBN-13: 978-0-672-33767-3 ISBN-10: 0-672-33767-3 Copy Editor Keith Cline Library of Congress Control Number: 2015917495 First Printing February 2016 Indexer Publishing Works Trademarks All terms mentioned in this book that are known to be trademarks or service marks have been Proofreader appropriately capitalized. Sams Publishing cannot attest to the accuracy of this information. Laura Hernandez Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark. Technical Editor Anne Groves Warning and Disclaimer Every effort has been made to make this book as complete and as accurate as possible, but Editorial Assistant no warranty or fitness is implied. The information provided is on an “as is” basis. The author Sandra Fugate and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book. Cover Designer Mark Shirar Special Sales For information about buying this title in bulk quantities, or for special sales opportunities Compositor (which may include electronic versions; custom cover designs; and content particular to your Nonie Ratcliff business, training goals, marketing focus, or branding interests), please contact our corporate sales department at [email protected] or (800) 382-3419. For government sales inquiries, please contact [email protected] . For questions about sales outside the U.S., please contact [email protected] . Contents at a Glance Introduction .................................................................................... 1 HOUR 1 Preparing Your System and iDevice for Development .......................... 5 2 Introduction to Xcode and the iOS Simulator ................................... 29 3 Discovering Swift and the iOS Playground ....................................... 73 4 Inside Cocoa Touch...................................................................... 123 5 Exploring Interface Builder ........................................................... 1 55 6 Model-View-Controller Application Design ..................................... 1 93 7 Working with Text, Keyboards, and Buttons ................................... 223 8 Handling Images, Animation, Sliders, and Steppers ........................ 259 9 Using Advanced Interface Objects and Views ................................. 291 10 Getting the User’s Attention .......................................................... 329 11 Implementing Multiple Scenes and Popovers .................................. 361 12 Making Choices with Toolbars and Pickers ..................................... 413 13 Advanced Storyboards Using Navigation and Tab Bar Controllers ............................................................................ 457 14 Navigating Information Using Table Views and Split View Controllers .................................................................................. 497 15 Reading and Writing Application Data ......................................... 539 16 Building Responsive User Interfaces ............................................... 585 17 Using Advanced Touches and Gestures .......................................... 627 18 Sensing Orientation and Motion ................................................... 663 19 Working with Rich Media ............................................................. 693 20 Interacting with Other iOS Services ............................................... 743 21 Implementing Location Services .................................................... 781 22 Building Background-Ready Applications ...................................... 813 23 Universal Applications and Size Classes ......................................... 853 24 Application Tracing, Monitoring, and Debugging........................... 877 Index .......................................................................................... 903 A Introducing Xcode Source Control .............................................Online Note: Appendix A is a bonus online chapter. To access it, go to www.informit.com/title/9780672337673 and click the Downloads tab. Table of Contents Introduction 1 Who Can Become an iOS Developer? ........................................................... 2 Who Should Use This Book? ........................................................................ 2 What Is (and Isn’t) in This Book? ................................................................ 3 Hour 1: Preparing Your System and iDevice for Development 5 Welcome to the iOS Platform ...................................................................... 5 Becoming an iOS Developer ...................................................................... 10 Running an iOS App ................................................................................ 15 Developer Technology Overview ................................................................ 22 Further Exploration .................................................................................. 24 Summary ................................................................................................ 24 Q&A ....................................................................................................... 24 Workshop ................................................................................................ 25 Activities ................................................................................................. 27 Hour 2: Introduction to Xcode and the iOS Simulator 29 Using Xcode ............................................................................................ 29 Using the iOS Simulator ........................................................................... 61 Further Exploration .................................................................................. 69 Summary ................................................................................................ 69 Q&A ....................................................................................................... 69 Workshop ................................................................................................ 70 Activities ................................................................................................. 72 Hour 3: Discovering Swift and the iOS Playground 73 Object-Oriented Programming and Swift .................................................... 73 The Terminology of Object-Oriented Development ...................................... 75 Exploring the Swift File Structure ............................................................... 78 Swift Programming Basics ......................................................................... 84 Memory Management and Automatic Reference Counting ........................ 110 Contents v Introducing the iOS Playground .............................................................. 111 Further Exploration ................................................................................ 118 Summary .............................................................................................. 119 Q&A ..................................................................................................... 119 Workshop .............................................................................................. 120 Activities ............................................................................................... 122 Hour 4: Inside Cocoa Touch 123 What Is Cocoa Touch? ............................................................................ 123 Exploring the iOS Technology Layers ....................................................... 125 Tracing the iOS Application Life Cycle ..................................................... 132 Cocoa Fundamentals .............................................................................. 134 Exploring the iOS Frameworks with Xcode ............................................... 142 Further Exploration ................................................................................ 149 Summary .............................................................................................. 149 Q&A ....................................................................................................
Recommended publications
  • Chapter 1. Origins of Mac OS X
    1 Chapter 1. Origins of Mac OS X "Most ideas come from previous ideas." Alan Curtis Kay The Mac OS X operating system represents a rather successful coming together of paradigms, ideologies, and technologies that have often resisted each other in the past. A good example is the cordial relationship that exists between the command-line and graphical interfaces in Mac OS X. The system is a result of the trials and tribulations of Apple and NeXT, as well as their user and developer communities. Mac OS X exemplifies how a capable system can result from the direct or indirect efforts of corporations, academic and research communities, the Open Source and Free Software movements, and, of course, individuals. Apple has been around since 1976, and many accounts of its history have been told. If the story of Apple as a company is fascinating, so is the technical history of Apple's operating systems. In this chapter,[1] we will trace the history of Mac OS X, discussing several technologies whose confluence eventually led to the modern-day Apple operating system. [1] This book's accompanying web site (www.osxbook.com) provides a more detailed technical history of all of Apple's operating systems. 1 2 2 1 1.1. Apple's Quest for the[2] Operating System [2] Whereas the word "the" is used here to designate prominence and desirability, it is an interesting coincidence that "THE" was the name of a multiprogramming system described by Edsger W. Dijkstra in a 1968 paper. It was March 1988. The Macintosh had been around for four years.
    [Show full text]
  • Interactive Music Visualization – Implementation, Realization and Evaluation MASTER DISSERTATION
    DM DM Interactive Music Visualization – Implementation, Realization and Evaluation MASTER DISSERTATION Nome Autor do Marco Filipe Ganança Vieira MASTER IN INFORMATICS ENGINEERING Interactive Music Visualization – Implementation, Interactive Music Visualization Realization and Evaluation Marco Filipe Ganança Vieira September | 2012 Nome do Projecto/Relatório/Dissertação de Mestrado e/ou Tese de Doutoramento | Nome do Projecto/Relatório/Dissertação de Mestrado e/ou Tese DIMENSÕES: 45 X 29,7 cm NOTA* PAPEL: COUCHÊ MATE 350 GRAMAS Caso a lombada tenha um tamanho inferior a 2 cm de largura, o logótipo institucional da UMa terá de rodar 90º , para que não perca a sua legibilidade|identidade. IMPRESSÃO: 4 CORES (CMYK) ACABAMENTO: LAMINAÇÃO MATE Caso a lombada tenha menos de 1,5 cm até 0,7 cm de largura o laoyut da mesma passa a ser aquele que consta no lado direito da folha. Interactive Music Visualization – Implementation, Realization and Evaluation MASTER DISSERTATION Marco Filipe Ganança Vieira MASTER IN INFORMATICS ENGINEERING ORIENTAÇÃO Mon-Chu Chen Abstract This thesis describes all process of the development of music visualization, starting with the implementation, followed by realization and then evaluation. The main goal is to have to knowledge of how the audience live performance experience can be enhanced through music visualization. With music visualization is possible to give a better understanding about the music feelings constructing an intensive atmosphere in the live music performance, which enhances the connection between the live music and the audience through visuals. These visuals have to be related to the live music, furthermore has to quickly respond to live music changes and introduce novelty into the visuals.
    [Show full text]
  • Trine University Information Technology Department Service Level Agreement
    TRINE UNIVERSITY INFORMATION TECHNOLOGY DEPARTMENT SERVICE LEVEL AGREEMENT EFFECTIVE DATE: August 6, 2012 SERVICE PROVIDER: Information Technology and Academic Technology Employees CUSTOMER: Trine University Administration and Faculty TYPE OF SERVICE: Technology Service and Support SCOPE: The I.T. Help Desk is the central point of contact for all service requests. Services provided: 1. Equipment (PC’s, printers, phones, etc.) and software moves, adds, or changes.* 2. Service requests such as user ID and password creation, phone and voice mail setup, creation of network folders, report requests, and assistance with Jenzabar, PowerFaids, Moodle, Microsoft Office or any other approved software. 3. Correction of problems or defects associated with any technology or telecommunications service. 4. Consulting and instruction associated with the use of technology. * See Appendix 1 for a list of Trine University standard hardware and software. Technology that competes or conflicts with these standards is not supported. Support Process: 1. A ticket is recorded for all requests with an email confirmation sent to the customer. 2. Tickets are resolved on first contact whenever possible, or assigned to the appropriate specialist. 3. Tickets status is monitored for adherence to service goals. 4. For services that require advance scheduling, customers are contacted to determine a suitable date and time. 5. Problem resolution is documented and communicated to customers verbally and/or via email. 6. Service metric reports are generated and shared with I.T. Sub-Committees. HOURS OF SERVICE: 7:00 a.m. to 7:00 p.m., Monday through Friday during the academic year (8:00 a.m. to 5:00 p.m.
    [Show full text]
  • Using Core Image on Ios and Mac OS X
    Using Core Image on iOS and Mac OS X Session 422 David Hayward Advanced Imaging Team These are confidential sessions—please refrain from streaming, blogging, or taking pictures 1 What We Will Discuss Today • Introducing Core Image on iOS 5 ■ Key concepts ■ Basic architecture ■ Classes and API ■ Platform specifics • Using Core Image in iOS ■ Initializing a CIImage ■ Filtering a CIImage ■ Rendering through a CIContext • Image analysis 2 Introducing Core Image in iOS 5 3 Basic Concept Filters perform per pixel operations on an image Sepia Filter Original Result The final result is a new image 4 Basic Concept Filters can be chained together Hue Sepia Contrast Adjust Filter Filter Filter Original Result This allows for complex effects 5 Basic Concept Filters chains are concatenated Hue Sepia Contrast Adjust Filter Filter Filter Original Result This eliminates intermediate buffers 6 Basic Concept Filters chains are optimized Color Color Sepia Matrix Matrix Filter Filter Filter Original Result This further improves performance 7 Basic Concept Filters chains are optimized Color Sepia Matrix Filter Filter Original Result This further improves performance 8 Basic Architecture Applications Core Graphics Core Video ImageIO ... Built-in Filters ... Core Image Runtime GPU Rendering CPU Rendering OpenGL ES 2.0 LibDispatch 9 Core Image Classes • CIFilter ■ A mutable object that represents an effect ■ Has image or numeric input parameters ■ Produces one output image based on current inputs • CIImage ■ An immutable object that represents the recipe for an image ■ Can represent a file from disk or the output of a CIFilter • CIContext ■ A object through which Core Image draw results ■ Can be based on on CPU or GPU 10 CIContext CPU vs.
    [Show full text]
  • Session 216 Cortis Clark Software Engineer
    Bringing Your iOS Apps to OS X Session 216 Cortis Clark Software Engineer These are confidential sessions—please refrain from streaming, blogging, or taking pictures At a Glance At a Glance 1. Rethink your design At a Glance 1. Rethink your design 2. Restructure your code At a Glance 1. Rethink your design 2. Restructure your code 3. Get started Rethink Your Design Embrace the Platform Rethink your app for OS X • Displays and windows iOS OS X Embrace the Platform Rethink your app for OS X • Input devices 44 x 44 Much More Precise Embrace the Platform Rethink your app for OS X Embrace the Platform Rethink your app for OS X • Menus and keyboard shortcuts Embrace the Platform Rethink your app for OS X • Menus and keyboard shortcuts • Undo and redo Embrace the Platform Rethink your app for OS X • Menus and keyboard shortcuts • Undo and redo • Drag and drop Embrace the Platform Rethink your app for OS X • Menus and keyboard shortcuts • Undo and redo • Drag and drop • Quick Look Embrace the Platform Rethink your app for OS X • Menus and keyboard shortcuts • Undo and redo • Drag and drop • Quick Look • Spotlight Restructure Your Code Leverage Existing Knowledge Leverage Existing Knowledge • Design patterns Leverage Existing Knowledge • Design patterns • Xcode Leverage Existing Knowledge • Design patterns • Xcode • Languages and frameworks Leverage Existing Knowledge • Design patterns • Xcode • Languages and frameworks • Resources Leverage Existing Knowledge • Design patterns • Xcode • Languages and frameworks • Resources • Localizations Technology
    [Show full text]
  • Core Animation for Mac OS X and the Iphone
    Prepared exclusively for Ki Wan Han What readers are saying about Core Animation for Mac OS X and the iPhone Animation isn’t “eye candy.” It’s about making GUI experiences less arbitrary and more comprehensible. The developers of Apple’s Core Animation get this, and so does Bill Dudney. His book offers a deep, thoughtful guide to the API and the ideas behind it. Chris Adamson Author of QuickTime for Java: A Developer’s Notebook It’s great to see a book for Mac developers that focuses on one topic and does it well. Its pace is excellent and will allow you to have sim- ple animations running in minutes. As the book goes deeper into its subject, it presents you with just the right amount of information to understand what you are doing so you don’t feel like you are just fol- lowing instructions, yet it never turns into a dry reference manual that overloads you with unnecessary detail. Steve (“Scotty”) Scott The Mac Developer Network (http://www.macdevnet.com) Finally! The comprehensive how-to guide we’ve been waiting for on all our Core Animation needs. Eric Wing Developer As an early adopter of Core Animation technology for the creation of Videator, I have but one regret: if only I had had Bill’s book, I would have finished it in half the time! Andrew Stone CEO, stone.com Prepared exclusively for Ki Wan Han Core Animation is an exciting new library for developers on both the iPhone and the Mac. Bill Dudney’s book makes a great companion for Cocoa programmers looking to add it to their bag of developer tricks.
    [Show full text]
  • Lecture Slides
    Music 3SI: So... Introduction to • Next week: audio effect >> FFT Audio/Multimedia App. • Plug-in: VST >> Max/Pd extern Programming • GUI: Cocoa > Qt ! VS on Windows: Ok (no support, though) ! any volunteer for demo...? Week #2 - 4/14/2006 • No Core Image CCRMA, Department of Music Stanford University • Installation help session 4/14/06, Music 3SI, CCRMA, Stanford That said... Today... • Not totally discarded • Digital audio basics ! sample code provided • Audio API: Stk (RtAudio) ! office-hour help/support available • Stk programming examples • Please let me know! ! signal generator ! file I/O ! realtime I/O • Other APIs ! PortAudio / ALSA / Core Audio 4/14/06, Music 3SI, CCRMA, Stanford 4/14/06, Music 3SI, CCRMA, Stanford Digital Audio • Audio signals stored in a digital format • Obtained by ! sampling analog signals Digital Audio ! creating digital samples by computation • Audio data as a sequence of samples 4/14/06, Music 3SI, CCRMA, Stanford 4/14/06, Music 3SI, CCRMA, Stanford Sampling More About Sampling • Sampling rate (or sampling frequency) ! determined by sampling interval ! 2 x upper limit of audio frequency • Quantization resolution ! range of numbers for each sample value ! determines dynamic range (i.e., 16-bit: 96[dB]) ! quantization loss 4/14/06, Music 3SI, CCRMA, Stanford 4/14/06, Music 3SI, CCRMA, Stanford See The Difference! Audio Programming 4/14/06, Music 3SI, CCRMA, Stanford 4/14/06, Music 3SI, CCRMA, Stanford Audio Programming... • Create audio sample data ! by computation, or ! sampling analog signals: ADC • Modify
    [Show full text]
  • Optimizing 2D Graphics and Animation Performance
    Optimizing 2D Graphics and Animation Performance Session 506 Tim Oriol Mike Funk These are confidential sessions—please refrain from streaming, blogging, or taking pictures Agenda Overview of topics for this session • Supporting Retina Display • Optimizing 2D graphics (Quartz 2D + Core Animation) • Identify and fix common Retina Display pitfalls • Using CGDisplayStream to get real-time display updates Prerequisites What you should know • Core Animation framework • Quartz 2D drawing techniques • Basic knowledge of UIView and NSView What Changes with Retina Displays? Retina Displays Today’s Retina Displays have 4x the pixels of previous displays Points Versus Pixels What’s the point • Points have nothing to do with typographer’s “points” • Points are logical coordinates • Pixels are actual device display coordinates • One point is not always equal to one pixel • The “scale factor” is the number of pixels per point • Use points with Quartz 2D, UIKit, AppKit, and Core Animation Retina Displays Set up your scale factor • Set the contentsScale property of layers that you would like to provide high-resolution content • Text, shapes, Quartz 2D drawing, and any layers that you have provided high-resolution images as content • UIKit/AppKit will set the appropriate contentsScale for layers they create layer.contentsScale = [UIScreen mainScreen].scale; Retina Displays Set up your scale factor • The CGContext provided to you via CALayer’s drawInContext will be set up correctly according to its contentsScale property • Any CGContextBitmap you create
    [Show full text]
  • Building an Image- and Video Processing Application on Apple Ios Platform Using a Parallel Programming Model
    Building an image- and video processing application on Apple iOS platform using a parallel programming model University of Oulu Faculty of Information Technology and Electrical Engineering / M3S Master’s Thesis Ari Ruokamo 25.4.2018 2 Abstract Today powerful parallel computer architectures empower numerous application areas in personal computing and consumer electronics and parallel computation is an established mainstay in personal mobile devices (PMD). During last ten years PMDs have been equipped with increasingly powerful parallel computation architectures (CPU+GPU) enabling rich gaming, photography and multimedia experiences and general purpose parallel computation through application programming interfaces such as OpenGL ES and Apple Metal. Using a narrative literature review this study viewed into current status of parallel computing and parallel programming and specifically its application and practices of digital image processing applied in the domain of Mobile Systems (MS) and Personal Mobile Devices (PMD). While the research on the context is an emerging topic, there still is a limited amount of research available on the topic. As acknowledged in the literature and in the practice, the OpenGL ES programming model for computing tasks can be a challenging environment for many programmers. With OpenGL ES, the paradigm shift from serial- to parallel programming, in addition to changes and challenges in used programming language and the tools supporting the development, can be a barrier for many programmers. In this thesis a Design Science Research (DSR) approach was applied to build an artefact – an image- and video processing application on Apple iOS software platform using OpenGL ES parallel programming model. An Open Source Software (OSS) parallel computing library GPUImage was applied in the implementation of the artefact filtering- and effects functionality.
    [Show full text]
  • Printfolio Getting Started Guide
    BeLight Software Printfolio Getting Started Guide Version 1 November 2010 (C) 2010 BeLight Software, Ltd. All rights reserved. BeLight Software, Ltd. reserves the right to improve, enhance and revise its products without notice. The information in this document is furnished for informational use only, is subject to change without notice, and should not be constructed as a commitment by BeLight Software, Ltd. BeLight Software assumes no liability for any errors or inaccuracies that may appear in this document. All trademarks, product and/or brand names mentioned in this publication, are the sole property of their respective owners. Written by Nick Shubin. Cover design by Viktoriya Naumova. Thanks to Ray East for help with the creation of this publication. Table of Contents 3 Contents Chapter 1: Introduction .................................. 5 Welcome to Printfolio ............................................................. 5 What is Included ................................................................... 5 System Requirements ............................................................ 5 Installing Printfolio ................................................................ 6 Removing Printfolio ............................................................... 6 Updating Printfolio ................................................................. 7 Licensing ............................................................................. 7 Technical Support .................................................................. 7 Useful Web
    [Show full text]
  • Creative Media Technology 1
    Creative Media Technology 1 companies, and other organizations throughout the business sector. CREATIVE MEDIA Upon completion of one of the associate degrees will also have designed and created a self-promotional package and professional, electronic TECHNOLOGY portfolio or demo reel. Associate of Applied Science Degrees High school students who are interested in a career in creative media are encouraged to take courses in art, photography, English, and • Digital Film mathematics. Courses as well as careers in media will require a person to • Digital Graphics Technology be able to work at computers, communicate verbally and in writing, and • Game Development participate in an online environment. Certificates of Completion Digital Film - Associate of Applied Science • Creative Media Digital Graphics Technology- Associate of Applied Science • Commercial Photography Game Development - Associate of Applied Science • Digital Audio Commercial Photography - Certificate of Completion • Digital Graphics • Digital Video Creative Media - Certificate of Achievement • Film Crew Training Digital Audio - Certificate of Completion • Game Design • Graphics and Animation Digital Graphics - Certificate of Completion • Web Design Digital Video - Certificate of Completion Because we live in the age of information, there is an ever-growing need Film Crew Training - Certificate of Completion for trained specialists with a visual sophistication to design printed materials and web sites, produce videos and films, create animated Game Design - Certificate of Completion scenes and characters, and participate in game design. Effective visual communication and interaction is essential in today’s world. Graphics and Animation - Certificate of Completion The program in Creative Media Technology has been developed in Web Design - Certificate of Completion response to all of these needs.
    [Show full text]
  • Music 3SI Introduction to Audio / Multimedia Application Programming
    Music 3SI handout #1, page 1/3 Friday, April 7, 2006 Music 3SI Introduction to Audio / Multimedia Application Programming Contact Info. Instructor (Course Leader): Woon Seung Yeo ([email protected]) Faculty Sponsor: Jonathan Berger (Chair, Department of Music) Time and Place Friday 1:15~3:05, Knoll classroom (660 Lomita Dr.) Course Website http://ccrma.stanford.edu/courses/3SI/ Introduction Music 3SI is an introduction to various topics of audio/multimedia programming. We explore the basics of programming tools and environments, software libraries, graphic user interface design, audio plug-in architecture, and network communication. As an introductory course, it is primarily targeted at musicians, artists, and/or entry-level program- mers who want to develop their own software. On the other hand, it provides an overview of audio/ multimedia programming topics to advanced programmers. This course is also designed to serve as a series of practical programming tutorial sessions for a number of courses offered at the Center for Computer Research in Music and Acoustics (CCRMA). Outline of Topics: Programming: - Basic concepts of C/C++ - Integrated Development Environments (IDE) - GUI design and implementation: Cocoa, Qt Audio: - Audio software design issue - Audio APIs: Stk - Introductory Audio DSP Audio Plug-ins: - VST plug-ins - Max/MSP and/or Pd externals Visual/Multimedia: - Graphic APIs and basic drawing programming - Multimedia application: merging audio with visual - Sonification and visualization Network communication: - Audio streaming - Open Sound Control (OSC) Woon Seung Yeo / CCRMA Music 3SI handout #1, page 2/3 Friday, April 7, 2006 Pre-requisites Beginner or intermediate level programming skill in C/C++.
    [Show full text]