O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Application Development with Swift

Book Description

Develop highly efficient and appealing iOS applications by using the Swift language

About This Book

  • Develop a series of applications with Swift using the development kits and new/updated APIs
  • Use the new features of iOS 8 to add new flavor to your applications
  • A hands-on guide with detailed code snippets to aid you in developing powerful Swift applications

Who This Book Is For

If you are an iOS developer with experience in Objective-C, and wish to develop applications with Swift, then this book is ideal for you. Familiarity with the fundamentals of Swift is an added advantage but not a necessity.

What You Will Learn

  • Use playgrounds in Xcode to make the writing of Swift code productive and easy
  • Get acquainted with the advanced features of Swift and make complete use of them in your code
  • Add a new method for authentication to your app using Touch ID
  • Develop health-related apps using HealthKit
  • Take your apps to the next level of performance and capability using Metal
  • Develop applications for wearables using WatchKit
  • Use Notification Center to easily access all your notifications
  • Make your users devices more stylish by using Apple's built-in Quick Type keyboard, instead of the native one

In Detail

After years of using Objective-C for developing apps for iOS/Mac OS, Apple now offers a new, creative, easy, and innovative programming language for application development, called Swift. Swift makes iOS application development a breeze by offering speed, security and power to your application development process. Swift is easy to learn and has awesome features such as being open source, debugging,interactive playgrounds, error handling model, and so on. Swift has simplified its memory management with Automatic Reference Counting (ARC) and it is compatible with Objective-C.

This book has been created to provide you with the information and skills you need to use the new programming language Swift. The book starts with an introduction to Swift and code structure. Following this, you will use playgrounds to become familiar with the language in no time. Then the book takes you through the advanced features offered by Swift and how to use them with your old Objective-C code or projects. You will then learn to use Swift in real projects by covering APIs such as HealthKit, Metal, WatchKit, and Touch ID in each chapter. The book's easy to follow structure ensures you get the best start to developing applications with Swift.

Style and approach

The book achieves its end goal by dividing its content into two parts. Part 1 will take the readers, who are new to Swift, through its architecture and basics. Part 2 of the book will cover content on application development with Swift.

Table of Contents

  1. Application Development with Swift
    1. Table of Contents
    2. Application Development with Swift
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Hello Swift
      1. Introduction to Swift
      2. Playgrounds
      3. The code structure
      4. Arrays
        1. Initializing an array
        2. Iterating over arrays
        3. Appending items
        4. Removing and updating items
      5. Dictionaries
        1. Initializing a dictionary
        2. Appending or updating values
        3. Removing items from the dictionary
      6. Enum
        1. Using enumerations with the switch statement
        2. Enumerations with associated values
      7. Functions
      8. Closures
      9. Summary
    9. 2. Advanced Swift
      1. Type casting and type checking
        1. Downcasting
      2. Using Any and AnyObject
      3. Protocols
        1. Properties
        2. Methods
        3. Class-only protocols
        4. Protocol compositions
        5. The protocol conformance
        6. The optional requirements
        7. Delegation
      4. Extensions
        1. Adding computed properties
        2. Adding new initializers
        3. Adding methods
      5. Generics
      6. Operator functions
      7. Memory management
      8. Using Objective-C and Swift in a single project
        1. Importing Objective-C in the Swift project
        2. Importing Swift in the Objective-C project
        3. Limitations
      9. Summary
    10. 3. Touch ID
      1. What is Touch ID?
      2. The LocalAuthentication framework
      3. Summary
    11. 4. Introduction to HealthKit
      1. What is HealthKit?
      2. HealthKit limitations
      3. HealthKit privacy
      4. Getting started with HealthKit
        1. Configuring the Xcode project
        2. Getting your hands dirty with HealthKit
          1. The HealthKit store
          2. Asking for permissions
          3. Updating the UI
          4. Sharing data in the Health app
      5. Summary
    12. 5. Introduction to Metal
      1. What is Metal?
      2. Features
      3. 3D rendering
        1. Pipeline
        2. Transformations
        3. Projection
      4. Other options to work with 3D rendering in iOS
      5. Getting started with Metal
        1. Devices and CAMetalLayers
        2. The command queue
        3. Vertex and color buffers
        4. Vertex and fragment shaders
        5. The render pipeline
        6. The game loop and rendering
          1. The display link
          2. The render pass
          3. The command buffer
      6. Summary
    13. 6. Introduction to WatchKit
      1. Apple watch
      2. WatchKit
        1. The WatchKit app
        2. Glances
        3. Actionable notifications
      3. Working with WatchKit
        1. Xcode targets
        2. Interface controllers
        3. Interface elements
          1. Groups
        4. Navigating interfaces
          1. Presenting modally
        5. Animation
        6. Working with glances
      4. Summary
    14. 7. Swift App Extensions
      1. App extensions
        1. Today
        2. Share
        3. Photo Editing
        4. Document Provider
          1. Understanding the Document Provider's lifecycle
        5. The custom keyboard
          1. Keyboard security
          2. Keyboard settings
          3. Working with the custom keyboard
      2. Demo
      3. Summary
    15. Index