Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

Application Development with Swift
Application Development with Swift
Application Development with Swift
Ebook260 pages1 hour

Application Development with Swift

Rating: 0 out of 5 stars

()

Read preview

About this ebook

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.

LanguageEnglish
Release dateAug 28, 2015
ISBN9781785282362
Application Development with Swift
Author

Hossam Ghareeb

Hossam Ghareeb is a software engineer who graduated from the computer and system engineering department of Alexandria University in 2012. Currently, he is an iOS software engineer at Prototype Interactive in Dubai. He has a lot of experience in iOS development and software engineering; he always keeps himself up to date with new technologies. It is his passion to help people by sharing his experience and writing tutorials to get people engaged quickly without problems. His favorite hobbies are fishing and playing video games, especially FIFA and PES. If you need his help or wish to go fishing with him, then you can contact him at hossam.ghareb@gmail.com.

Related to Application Development with Swift

Related ebooks

Programming For You

View More

Related articles

Reviews for Application Development with Swift

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    Application Development with Swift - Hossam Ghareeb

    Table of Contents

    Application Development with Swift

    Credits

    About the Author

    About the Reviewers

    www.PacktPub.com

    Support files, eBooks, discount offers, and more

    Why subscribe?

    Free access for Packt account holders

    Preface

    What this book covers

    What you need for this book

    Who this book is for

    Conventions

    Reader feedback

    Customer support

    Downloading the example code

    Errata

    Piracy

    Questions

    1. Hello Swift

    Introduction to Swift

    Playgrounds

    The code structure

    Arrays

    Initializing an array

    Iterating over arrays

    Appending items

    Removing and updating items

    Dictionaries

    Initializing a dictionary

    Appending or updating values

    Removing items from the dictionary

    Enum

    Using enumerations with the switch statement

    Enumerations with associated values

    Functions

    Closures

    Summary

    2. Advanced Swift

    Type casting and type checking

    Downcasting

    Using Any and AnyObject

    Protocols

    Properties

    Methods

    Class-only protocols

    Protocol compositions

    The protocol conformance

    The optional requirements

    Delegation

    Extensions

    Adding computed properties

    Adding new initializers

    Adding methods

    Generics

    Operator functions

    Memory management

    Using Objective-C and Swift in a single project

    Importing Objective-C in the Swift project

    Importing Swift in the Objective-C project

    Limitations

    Summary

    3. Touch ID

    What is Touch ID?

    The LocalAuthentication framework

    Summary

    4. Introduction to HealthKit

    What is HealthKit?

    HealthKit limitations

    HealthKit privacy

    Getting started with HealthKit

    Configuring the Xcode project

    Getting your hands dirty with HealthKit

    The HealthKit store

    Asking for permissions

    Updating the UI

    Sharing data in the Health app

    Summary

    5. Introduction to Metal

    What is Metal?

    Features

    3D rendering

    Pipeline

    Transformations

    Projection

    Other options to work with 3D rendering in iOS

    Getting started with Metal

    Devices and CAMetalLayers

    The command queue

    Vertex and color buffers

    Vertex and fragment shaders

    The render pipeline

    The game loop and rendering

    The display link

    The render pass

    The command buffer

    Summary

    6. Introduction to WatchKit

    Apple watch

    WatchKit

    The WatchKit app

    Glances

    Actionable notifications

    Working with WatchKit

    Xcode targets

    Interface controllers

    Interface elements

    Groups

    Navigating interfaces

    Presenting modally

    Animation

    Working with glances

    Summary

    7. Swift App Extensions

    App extensions

    Today

    Share

    Photo Editing

    Document Provider

    Understanding the Document Provider's lifecycle

    The custom keyboard

    Keyboard security

    Keyboard settings

    Working with the custom keyboard

    Demo

    Summary

    Index

    Application Development with Swift


    Application Development with Swift

    Copyright © 2015 Packt Publishing

    All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

    Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

    Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

    First published: August 2015

    Production reference: 1250815

    Published by Packt Publishing Ltd.

    Livery Place

    35 Livery Street

    Birmingham B3 2PB, UK.

    ISBN 978-1-78528-817-3

    www.packtpub.com

    Credits

    Author

    Hossam Ghareeb

    Reviewers

    Tyler Hackbart

    David Mattia

    Hossam M. Sherif

    Kenneth Strickland

    Commissioning Editor

    Julian Ursell

    Acquisition Editor

    Nikhil Karkal

    Content Development Editor

    Shali Deeraj

    Technical Editor

    Prajakta Mhatre

    Copy Editor

    Charlotte Carneiro

    Project Coordinator

    Kinjal Bari

    Proofreader

    Safis Editing

    Indexer

    Tejal Soni

    Graphics

    Sheetal Aute

    Disha Haria

    Production Coordinator

    Melwyn D'sa

    Cover Work

    Melwyn D'sa

    About the Author

    Hossam Ghareeb is a software engineer who graduated from the computer and system engineering department of Alexandria University in 2012. Currently, he is an iOS software engineer at Prototype Interactive in Dubai. He has a lot of experience in iOS development and software engineering; he always keeps himself up to date with new technologies. It is his passion to help people by sharing his experience and writing tutorials to get people engaged quickly without problems. His favorite hobbies are fishing and playing video games, especially FIFA and PES. If you need his help or wish to go fishing with him, then you can contact him at <hossam.ghareb@gmail.com>.

    I would like to thank each and every person who has been helpful to me, from my teaching staff to my friends. A special thanks to my lovely wife, Amira, for all her support and encouragement in spite of all the time this book kept me away from her. I thank my son, Yusuf, for inspiring me. I would also like to express my sincere gratitude toward my parents for teaching me how to be a good person.

    Last but not least, I would like to thank the content editors, Shali Deeraj and Nikhil Karkal, for helping me and being nice to me, and the reviewers for their helpful comments and suggestions.

    About the Reviewers

    Tyler Hackbart is a web developer, designer, and technology enthusiast with a passion for everything in technology. Through self-learning, he gained the ability to write his first line of code when he was only 16 years old and has just started learning his sixth programming language. With his farm-raised work ethic, alongside a passion for crafting amazing user interactions and doing what he loves, Tyler has successfully worked in the technology field for 2 years. He is the cofounder of three start-ups and works in an application design firm, all based in Waterloo, Canada.

    David Mattia is a student at the University of Notre Dame with a passion for software engineering. He has worked for General Electric Aviation and spends much of his free time doing freelance work.

    Hossam M. Sherif is a software developer. He received his bachelor's degree in computer and system engineering from Alexandria University. He has spent several years in software development, especially in iOS and backend development. He has worked with many companies, such as Insidetrack, Inova LLC, and Log n Labs. He worked on different projects and in different roles, from software developer to team leader and manager. He served in the Egyptian Navy and participated in the enhancement and development of the IT department. He has certificates in software test processes and software test design. He participated in several volunteer projects and workshops as an instructor for Introduction to iOS Development, a summer 2014 training course for undergraduates at Alexandria University, and also other courses, such as the Alexandria Startup 2012 weekend and IEEE ITW 2011.

    Kenneth Strickland joined the US Army in 1986. After 4 years of active duty in the US Army, he came across software development. That was when he picked up his first C programming book and read it from cover to cover. Since then, he has never looked back.

    He has been a software architect for over 10 years, and currently develops applications primarily in C/C++, Java, Objective-C, Swift, and .NET.

    You can visit his website at http://kenster.guru.

    www.PacktPub.com

    Support files, eBooks, discount offers, and more

    For support files and downloads related to your book, please visit www.PacktPub.com.

    Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at for more details.

    At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

    https://www2.packtpub.com/books/subscription/packtlib

    Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.

    Why subscribe?

    Fully searchable across every book published by Packt

    Copy and paste, print, and bookmark content

    On demand and accessible via a web browser

    Free access for Packt account holders

    If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.

    Preface

    This book teaches you how to master the Swift programming language and use it in building apps with the new technologies introduced in iOS 8. Swift is a new programming language for iOS, OS X, and watchOS apps. In the beginning of this book, we will give you an advanced introduction to Swift, and then we will see how to apply this in real-app demos using the new technologies and APIs in iOS 8 such as TouchID, watchOS, Metal, and HealthKit.

    What this book covers

    Chapter 1, Hello Swift, gives a quick introduction and revision about Swift. This chapter is very important for Swift beginners and is highly recommended for Swift developers to revise their knowledge.

    Chapter 2, Advanced Swift, boosts your Swift experience by allowing you to learn some advanced features in Swift. In this chapter, we will talk about protocols, extensions, and

    Enjoying the preview?
    Page 1 of 1