Beginning iPhone Development with Swift

Exploring the iOS SDK

By David Mark , Jack Nutting , Kim Topley , Fredrik Olsson , Jeff LaMarche

The team that brought you the bestselling Beginning iPhone Development, the book that taught the world to program on the iPhone, has been transformed to deliver the same excellent introduction to iPhone and iOS programming using Swift. Beginning iPhone Development with Swift introduces you to Swift in this definitive guide up-to-date with Apple's latest and greatest new iOS 8 and its SDK, as well as with the latest version of Xcode 6. (Source code now updated to reflect Xcode 6.1.1!)

Full Description

  • ISBN13: 978-1-484204-10-8
  • 828 Pages
  • User Level: Beginner to Intermediate
  • Publication Date: November 19, 2014
  • Available eBook Formats: EPUB, MOBI, PDF
  • Print Book Price: $44.99
  • eBook Price: $31.99
Buy eBook Buy Print Book Add to Wishlist

Related Titles

Full Description

The team that brought you the bestselling Beginning iPhone Development, the book that taught the world how to program on the iPhone, is back again for Beginning iPhone Development with Swift.This definitive guide is up to date with Apple's new Swift programming language and the latest and greatest iOS 8 SDK, and Xcode 6.1.

There’s coverage of brand-new technologies, including Swift playgrounds, as well as significant updates to existing material. You'll have everything you need to create your very own apps for the latest iOS devices. Every single sample app in the book has been rebuilt from scratch using the latest Xcode and the latest 64-bit iOS 8-specific project templates, and designed to take advantage of the latest Xcode features.

Assuming little or no working knowledge of the new Swift programming language, and written in a friendly, easy-to-follow style, this book offers a complete soup-to-nuts course in iPhone, iPad, and iPod touch programming. The book starts with the basics, walking through the process of downloading and installing Xcode 6.1 and the iOS 8 SDK, and then guides you though the creation of your first simple application.

From there, you’ll learn how to integrate all the interface elements iOS users have come to know and love, such as buttons, switches, pickers, toolbars, and sliders. You’ll master a variety of design patterns, from the simplest single view to complex hierarchical drill-downs. The art of table building will be demystified, and you’ll learn how to save your data using the iPhone file system. You’ll also learn how to save and retrieve your data using a variety of persistence techniques, including Core Data and SQLite. And there’s much more!

What you’ll learn

  • Everything you need to know to develop your own bestselling iPhone and iPad apps
  • Utilizing Swift playgrounds
  • Best practices for optimizing your code and delivering great user experiences
  • What data persistence is, and why it’s important
  • Get started with building cool, crisp user interfaces
  • How to display data in Table Views
  • How to draw to the screen using Core Graphics
  • How to use iOS sensor capabilities to map your world
  • How to get your app to work with iCloud and more

Who this book is for

This book is for aspiring iPhone app developers, new to the Apple Swift programming language and/or the iOS SDK.

Table of Contents

Table of Contents

1. Welcome to the Swift Jungle

2. Appeasing the Tiki Gods

3. Handling Basic Interaction

4. More User Interface Fun

5. Rotation and Adaptive Layout

6. Multiview Applications

7. Tab Bars and Pickers

8. Introduction to Table Views

9. Navigation Controllers and Table Views

10. Collection Views

11. iPad Considerations

12. Application Settings and User Defaults

13. Basic Data Persistence

14. Hey! You! Get onto iCloud!

15. Grand Central Dispatch, Background Processing, and You

16. Core Graphics: Drawing with Quartz

17. Getting Started with Sprite Kit

18. Taps, Touches, and Gestures

19. Where Am I? Finding Your Way with Core Location and Map Kit

20. Whee! Gyro and Accelerometer!

21. The Camera and Photo Library

22. Application Localization

23. Appendix: A Swift Introduction to Swift

Source Code/Downloads

Downloads are available to accompany this book.

Your operating system can likely extract zipped downloads automatically, but you may require software such as WinZip for PC, or StuffIt on a Mac.

Errata

Please Login to submit errata.

On page 254:
In Xcode 6.1.1, Apple changed the mapping from Objective-C to Swift of several properties. As a result, some of the example code in the printed book no longer compiles. The source code archive on the book’s site has been updated. Changes to the relevant text are listed below:
Author Comment:
In UITableView Cell, imageView has changed from UIImageView to UIImageView? and textLabel from UILabel to UILabel?. Make the following changes:

Replace “cell!.textLabel.text” with “cell!.textLabel?.text”

On page 256:
In Xcode 6.1.1, Apple changed the mapping from Objective-C to Swift of several properties. As a result, some of the example code in the printed book no longer compiles. The source code archive on the book’s site has been updated. Changes to the relevant text are listed below:
Author Comment:
In UITableView Cell, imageView has changed from UIImageView to UIImageView? and textLabel from UILabel to UILabel?. Make the following changes:

Replace “cell!.textLabel.text” with “cell!.textLabel?.text”

On page 258:
In Xcode 6.1.1, Apple changed the mapping from Objective-C to Swift of several properties. As a result, some of the example code in the printed book no longer compiles. The source code archive on the book’s site has been updated. Changes to the relevant text are listed below:
Author Comment:
In UITableView Cell, imageView has changed from UIImageView to UIImageView? and textLabel from UILabel to UILabel?. Make the following changes:

Replace “cell!.imageView.image” with “cell!.imageView?.image”.

Replace “cell!.imageView.highlightedImage” with “cell!.imageView?.highlightedImage”.

Replace “cell!.textLabel.text” with “cell!.textLabel?.text”

On page 260:
In Xcode 6.1.1, Apple changed the mapping from Objective-C to Swift of several properties. As a result, some of the example code in the printed book no longer compiles. The source code archive on the book’s site has been updated. Changes to the relevant text are listed below:
Author Comment:
In UITableView Cell, imageView has changed from UIImageView to UIImageView? and textLabel from UILabel to UILabel?. Make the following changes:

Replace “cell!.textLabel.text” with “cell!.textLabel?.text”

On page 266:
In Xcode 6.1.1, Apple changed the mapping from Objective-C to Swift of several properties. As a result, some of the example code in the printed book no longer compiles. The source code archive on the book’s site has been updated. Changes to the relevant text are listed below:
Author Comment:
In UITableView Cell, imageView has changed from UIImageView to UIImageView? and textLabel from UILabel to UILabel?. Make the following changes:

Replace “cell!.textLabel.text” with “cell!.textLabel?.text”

Replace “cell!.textLabel.font” with “cell!.textLabel?.font”

On page 283:
In Xcode 6.1.1, Apple changed the mapping from Objective-C to Swift of several properties. As a result, some of the example code in the printed book no longer compiles. The source code archive on the book’s site has been updated. Changes to the relevant text are listed below:
Author Comment:
In UITableView Cell, imageView has changed from UIImageView to UIImageView? and textLabel from UILabel to UILabel?. Make the following changes:

Replace “cell.textLabel.text” with “cell.textLabel?.text”.

On page 293:
In Xcode 6.1.1, Apple changed the mapping from Objective-C to Swift of several properties. As a result, some of the example code in the printed book no longer compiles. The source code archive on the book’s site has been updated. Changes to the relevant text are listed below:
Author Comment:
In UITableView Cell, imageView has changed from UIImageView to UIImageView? and textLabel from UILabel to UILabel?. Make the following changes:

Replace “cell.textLabel.text” with “cell.textLabel?.text”.

On page 314:
In Xcode 6.1.1, Apple changed the mapping from Objective-C to Swift of several properties. As a result, some of the example code in the printed book no longer compiles. The source code archive on the book’s site has been updated. Changes to the relevant text are listed below:
Author Comment:
This chapter is also affected by the UITableViewCell changes:

Replace “cell.textLabel.font” with “cell.textLabel?.font”

Replace “cell.textLabel.text” with “cell.textLabel?.text”

On page 317:
In Xcode 6.1.1, Apple changed the mapping from Objective-C to Swift of several properties. As a result, some of the example code in the printed book no longer compiles. The source code archive on the book’s site has been updated. Changes to the relevant text are listed below:
Author Comment:
This chapter is also affected by the UITableViewCell changes:

Replace “cell.textLabel.font” with “cell.textLabel?.font”

Replace “cell.textLabel.text” with “cell.textLabel?.text”

On page 322:
In Xcode 6.1.1, Apple changed the mapping from Objective-C to Swift of several properties. As a result, some of the example code in the printed book no longer compiles. The source code archive on the book’s site has been updated. Changes to the relevant text are listed below:
Author Comment:
This chapter is also affected by the UITableViewCell changes:

Replace “cell.textLabel.font” with “cell.textLabel?.font”

Replace “cell.textLabel.text” with “cell.textLabel?.text”


On page 341:
In Xcode 6.1.1, Apple changed the mapping from Objective-C to Swift of several properties. As a result, some of the example code in the printed book no longer compiles. The source code archive on the book’s site has been updated. Changes to the relevant text are listed below:
Author Comment:
UICollectionViewController.collectionView has changed from type UICollectionView to UICollectionView?, requiring the following changes:

Replace “collectionView. “ with “collectionView!.” In three places.

On page 345:
In Xcode 6.1.1, Apple changed the mapping from Objective-C to Swift of several properties. As a result, some of the example code in the printed book no longer compiles. The source code archive on the book’s site has been updated. Changes to the relevant text are listed below:
Author Comment:
UICollectionViewController.collectionView has changed from type UICollectionView to UICollectionView?, requiring the following changes:

Replace “collectionView.” with “collectionView!”.

On page 347:
In Xcode 6.1.1, Apple changed the mapping from Objective-C to Swift of several properties. As a result, some of the example code in the printed book no longer compiles. The source code archive on the book’s site has been updated. Changes to the relevant text are listed below:
Author Comment:
UICollectionViewController.collectionView has changed from type UICollectionView to UICollectionView?, requiring the following changes:

Replace “collectionView.” with “collectionView!” in the first line of the page.

On page 366:
In Xcode 6.1.1, Apple changed the mapping from Objective-C to Swift of several properties. As a result, some of the example code in the printed book no longer compiles. The source code archive on the book’s site has been updated. Changes to the relevant text are listed below:
Author Comment:
This chapter is also affected by the UITableViewCell changes:

Replace “cell.textLabel.text” with “cell.textLabel?.text” twice (the first is in crossed-out code).


On page 373:
In Xcode 6.1.1, Apple changed the mapping from Objective-C to Swift of several properties. As a result, some of the example code in the printed book no longer compiles. The source code archive on the book’s site has been updated. Changes to the relevant text are listed below:
Author Comment:
This chapter is also affected by the UITableViewCell changes:

Replace “cell.textLabel.text” with “cell.textLabel?.text”.

On page 480:
In Xcode 6.1.1, Apple changed the mapping from Objective-C to Swift of several properties. As a result, some of the example code in the printed book no longer compiles. The source code archive on the book’s site has been updated. Changes to the relevant text are listed below:
Author Comment:
The changes to UITableViewCell affect this chapter too:

Replace “cell.textLabel.” with “cell.textLabel!.”


On page 492:
In Xcode 6.1.1, Apple changed the mapping from Objective-C to Swift of several properties. As a result, some of the example code in the printed book no longer compiles. The source code archive on the book’s site has been updated. Changes to the relevant text are listed below:
Author Comment:
UIDocument.undoManager has changed from NSUndoManager? to NSUndoManager:

Replace “document.undoManager?” with “document.undoManager” in two places.

On page 502:
In Xcode 6.1.1, Apple changed the mapping from Objective-C to Swift of several properties. As a result, some of the example code in the printed book no longer compiles. The source code archive on the book’s site has been updated. Changes to the relevant text are listed below:
Author Comment:
In NSURL, lastPathComponent was type String, but is now String?, so:

Replace “url.lastPathComponent” with “url.lastPathComponent!”