Book description
Dive into the latest release of the Swift programming language with this advanced Apple development book
About This Book
- Discover the new features and improvements to Swift 3
- Get to grips with advanced design patterns and techniques to write smarter, cleaner Swift code
- Become a more fluent Swift developer and build powerful, impressive iOS and OS X applications.
Who This Book Is For
This book is for developers who want to dive into the newest version of Swift.
If you are a developer that learns best by looking at, and working with code, then this book is for you. A basic understanding of Apple's tools is beneficial but not mandatory.
What You Will Learn
- Dive into the core components of Swift 3.0, including operators, collections, control flow, and functions
- Create and use classes, structures, and enums
- Understand object-oriented Swift and see how to tackle inheritance, protocols, and extensions
- Develop a practical understanding of subscripts, optionals, and closures
- See how to use the new protocol extension and error handling features of Swift 3.0
- Add concurrency to your applications using Grand Central Dispatch
In Detail
Swift is the definitive language of Apple development today. It's a vital part of any iOS and OS X developer's skillset, helping them to build the most impressive and popular apps on the App Store - the sort of apps that are essential to iPhone and iPad users every day. With version 3.0, the Swift team have added new features to improve the development experience - making it easier to get the results you want and customers expect.
Inside, you'll find the key features of Swift 3.0 and quickly learn how to use the newest updates to your development advantage. From Objective-C interoperability to ARC, to closures and concurrency, this advanced Swift guide will develop your expertise and make you more fluent in this vital programming language.
We give you in-depth knowledge of some of the most sophisticated elements of Swift development including protocol extensions, error-handling, design patterns, and concurrency, and guide you on how to use and apply them in your own projects. You'll see how even the most challenging design patterns and programming techniques can be used to write cleaner code and to build more performant iOS and OS X applications.
By the end of this book, you'll have a handle on effective design patterns and techniques, which means you'll soon be writing better iOS and OS X applications with a new level of sophistication and control.
Style and approach
Packed with practical examples that show you how to put the concepts you learn into practice quickly, we'll takes you through some of the most advanced and sophisticated elements of the language in a practical and actionable way. You can also download the code to use yourself
Table of contents
-
Mastering Swift 3
- Mastering Swift 3
- Credits
- About the Author
- About the Reviewer
- www.PacktPub.com
- Preface
-
1. Taking the First Steps with Swift
- What is Swift?
-
Playgrounds
- Getting started with Playgrounds
- iOS and OS X Playgrounds
- Showing images in a Playground
- Creating and displaying graphs in Playgrounds
- What Playgrounds are not
- Swift language syntax
- Comments
- Semicolons
- Parentheses
- Curly brackets for control statements
- An assignment operator does not return a value
- Spaces are optional in conditional and assignment statements
- Hello World
- Summary
- 2. Learning About Variables, Constants, Strings, and Operators
-
3. Using Swift Collections and the Tuple Type
- Swift collection types
- Mutability
-
Arrays
- Creating and initializing arrays
- Accessing the array elements
- Counting the elements of an array
- Is the array empty?
- Appending to an array
- Inserting a value into an array
- Replacing elements in an array
- Removing elements from an array
- Merging two arrays
- Reversing an array
- Retrieving a subarray from an array
- Making bulk changes to an array
- Algorithms for arrays
- Iterating over an array
- Dictionaries
- Set
- Tuples
- Summary
- 4. Control Flow and Functions
- 5. Classes and Structures
- 6. Using Protocols and Protocol Extensions
- 7. Protocol-Oriented Design
- 8. Writing Safer Code with Availability and Error Handling
- 9. Custom Subscripting
- 10. Using Optional Types
- 11. Working with Generics
- 12. Working with Closures
-
13. Using Mix and Match
- What is mix and match?
- When to use mix and match
-
Using Swift and Objective-C together in the same project
- Creating the project
- Adding Swift files to the Objective-C project
- The Objective-C bridging header file – part 1
- Adding the Objective-C file to the project
- The Messages Objective-C class
- The Objective-C Bridging Header file – part 2
- The MessageBuilder Swift class – accessing Objective-C code from Swift
- The Objective-C class - accessing Swift code from Objective-C
- Summary
- 14. Concurrency and Parallelism in Swift
-
15. Swift Formatting and Style Guide
- What is a programming style guide?
-
Your style guide
- Do not use semicolons at the end of statements
- Do not use parentheses for conditional statements
- Naming
- Comments
- Using the self keyword
- Constants and variables
- Optional types
- Use type inference
- Use shorthand declaration for collections
- Use switch rather than multiple if statements
- Don't leave commented-out code in your application
- Summary
- 16. Swifts Core Libraries
- 17. Adopting Design Patterns in Swift
Product information
- Title: Mastering Swift 3
- Author(s):
- Release date: October 2016
- Publisher(s): Packt Publishing
- ISBN: 9781786466129
You might also like
book
Swift: Developing iOS Applications
Unleash the power of Swift and discover the skills required to build incredible robust iOS applications …
book
Swift 4 Programming Cookbook
Over 50 recipes to help you quickly and efficiently build applications with Swift 4 and Xcode …
book
iOS Development with Swift
iOS Development with Swift is a hands-on guide to creating apps for iPhone and iPad using …
book
Programming iOS 13
If you’re grounded in the basics of Swift, Xcode, and the Cocoa framework, this book provides …