Understanding Swift ProgrammingCraig A. Will
Available now from Amazon.com in paperback for $18.95 and on Kindle for $9.99.
Available now on Apple iBooks (epub) and on Kobo Books (epub).
Includes Hands-on Online Programming Exercises for each chapter.
Tenaya Creek Press
ISBN-13: 978-0996228107, ISBN-10: 0996228101
392 pages, 6" x 9"
(Scroll down to see an enlarged version of the cartoon on the cover.)
Also see the book News Without the Mad Men
Swift Changes & Errata for this book.
This book, aimed at readers with some programming experience, will provide you with what you need to learn the new language. Written in easy-to-understand English rather than technical jargon, the book takes readers first through the fundamentals of essential topics. Later chapters fill in more advanced nuances.
First Swift 2 Book in Print
This is the first Swift programming book available in print form that covers the new Swift version 2. The book's coverage of Swift 2 includes full chapters on Error Handling and on Protocol Oriented Programming, two of its major advances. The talk on Protocol Oriented Programming was the most popular presentation at Apple's June, 2015 World Wide Developer's Conference at which Swift 2 was announced.
Protocol oriented programming is a lightweight alternative to classes and inheritance that is typically safer and results in less coupling between objects. Structures, Swift's safer, lighter-weight alternative to classes, can effectively obtain implementations of methods from protocols, much as classes inherit methods. However, this is done with a smaller grain size, a safer approach to memory sharing, and no inheritance chains.
The book also covers other new Swift features including:
Checking API Availability, New Syntax for Print, Guard Statements, Repeat-While Statements, New Optionals Pattern, Statement Labels, & Markdown in Playgrounds.
Hands-on Online Exercises. It is common for programmers learning a new language to read a book on the topic, but when they start to write code, realize that they have retained little from the book.
This book avoids this with the use of extensive hands-on, on-line exercises. Chapters are relatively short, and after every chapter readers are asked to go with their Macintosh or PC to a web address for that chapter that actively tests and reinforces what the readers have just learned. Studies have shown that such exercises can engage readers in a way that passive reading cannot and result in huge gains in retention of the material.
Better retention of code means that you can write code without hesitation, without looking it up. Better retention of concepts means that you will more easily understand additional material, including some of the more difficult concepts in Swift that may be new to you, such as optional values, closures, structures, enumerations, and protocol-oriented programming.
The book contains over 35 cartoons, lightening the mood of the book, and each highlighting some aspect of the Swift language in a visual and fun way that engages readers.
The book consists of thirty-five chapters and five appendices, divided into four major parts, as follows:
PART 1: FUNDAMENTALS
1. Data Types
3. Flow of Control
7. Strings and Characters
9. Optional Values
PART 2: OBJECT-ORIENTED PROGRAMMING
11. Object-Oriented Programming
12. Classes, Objects, and Inheritance
13. Functions and Methods
16. Properties and Class or Type Methods
PART 3: ADDITIONAL TOPICS
17. Functions Revisited: First Class Citizens
18. Closures and Closure Expressions
19. Memory Management
20. Switch Statements Revisited
21. Error Handling
22. Functions Revisited Again: Input Parameters
23. Variations in Closure Expression Syntax
24. Custom Subscripts
25. Operators Revisited: Overloading and Custom Operators
26. Optional Values Revisited
27. Access Control
PART 4: OOP REVISITED
28. Generic Programming
29. Objects Revisited: Initializers
30. Type Casting
31. Enumerations Revisited
34. Protocol Oriented Programming
35. Mixed Swift and Objective-C Programs
A. What's Different About Swift?
C. The REPL Loop
D. Further Information