When I started writing this edition of this book (which has been in the field and regularly updated since iOS version 4), I thought to myself: what I should do to really overhaul it and make it even more exciting than the previous editions? The answer was to rewrite the whole book—every single word from scratch. Up to and including the iOS 8 Swift Programming Cookbook (where I made the big switch from Objective-C to Swift) was to base every edition on the previous edition. I would go through all the examples from the previous edition to remove the ones that were irrelevant for the new edition or just expendable because they were very simple and basic. I’d then update the remaining examples to make sure they work great with the new iOS version. Then I would also write new content for the new version of iOS. However, after 5 editions, I noticed that many recipes were not really useful anymore and had stayed almost the same since the beginning. So how could I solve this issue? The solution was to not do this any longer. I had to write all new content, and that’s what I did for this book.
The amount of work that went into writing this book was tremendous, on my side and on O’Reilly’s side. I have had to think long and hard about every new recipe, writing all the example code anew and ensuring it works with the latest production tools from Apple. You will learn a lot about Swift 2 and iOS 9 SDK in this book.
And yes, there is a great deal of watchOS material in this book. The chapter dedicated to watchOS has more content in it than any other chapter. The reason behind that decision was that watchOS was the main focus for this year’s WWDC and that Apple has paid more attention to watchOS in iOS 9 SDK than to other frameworks or tools that they have published this year. I hope you’ll enjoy writing watchOS apps as much as I do.
One last thing. Since Swift changes a lot and is constantly updated, please always check the GitHub repo for this book to get the most up-to-date code. I have ensured that all code compiles and works fine with Xcode 7 and the iOS 9 SDK, but if for some reason you are on a beta Xcode that is newer than the production version of Xcode 7 that Apple has released, do ensure that you have the latest code by checking out this book’s GitHub repo.
Have fun and I hope you’ll enjoy reading this book.
I assume that you are comfortable writing iOS apps, at least know your way around Xcode, and can work with the simulator. This book is not for beginners. If you have never programmed in Xcode before for iOS, it will be tough to learn iOS programming only from this book. So I suggest that you complement your skills with other online resources. The best market for this book is intermediate and advanced users.
I also assume that you have written a little bit of Swift code. In this book, I use Swift 2 and will teach you some of the concepts, but if you don’t know Swift, this is not the right place to start. Please pick up Apple’s book on Swift programming first; try with that and once you are a bit comfortable with Swift, come back to this book and I’m sure you’ll learn a lot of new things, even about Swift 2.
Here I’ll explain what each chapter is about so that you’ll get a feeling for what this book is going to teach you:
guard
keyword to Swift and conditionally extending types with Swift’s new runtime features. Swift has really matured with Swift 2, and I want to share some of the most important additions with you.This book is not for beginners, so I assume you have already gotten a grip on Swift and can do basic things with it. Please read Apple’s documentation on Swift by doing a quick web search. You can either read it on your browser, as a PDF, or you can read it in iBooks.
Also please check this book’s GitHub repository in order to get the most up-to-date code, as I update the code to ensure it works with the latest Swift and Xcode versions.
Supplemental material (code examples, exercises, etc.) is available for download at https://github.com/vandadnp/iOS-9-Swift-Programming-Cookbook.
This book is here to help you get your job done. In general, if example code is offered with this book, you may use it in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “iOS 9 Swift Programming Cookbook by Vandad Nahavandipoor (O’Reilly). Copyright 2016 Vandad Nahavandippor, 978-1-491-93669-6.”
If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at [email protected].
Thank you to: