Pro Swift Hacking With Swift Books

Pro Swift
Pro Swift

DOWNLOAD Pro Swift Book

Pro Swift Book Details

Title: Pro Swift
Author: Paul Hudson
Language: English
No. of pages: 281
Format: PDF

Preface Pro Swift Book

Andy Matuschak (@andy_matuschak), lead mobile developer at Khan Academy

If you’re transforming a collection, but you don’t need to access all the elements right away (or at all), you may be able to save cycles and allocations by using the lazy family of collection types:

let userCellsData = { user in
   UserCellData(username: user.username, bioAttributedString:

Welcome To Pro Swift

This is not a book for people who are new to Swift. I realize that’s obvious given that the book is called Pro Swift, but I want to make sure we’re getting off on the right foot. Instead, this is a book for people who have some real-world knowledge of the language – perhaps you’ve made some apps yourself, perhaps you’ve read through Apple’s official Swift reference guide, or perhaps you even read my first book, Hacking with Swift.

It is not required that you have read Hacking with Swift in order to make the most of this book, but I have to admit it certainly helps. At the very least you should have read the introduction chapter, which goes through the basics of Swift in about an hour of coding. If you haven’t already read that chapter, I suggest you pause here then go and read it at https:// before continuing.

If you’re still here, I’m assuming it means you’re ready to learn about what’s in this book. Well, I have some good news: I have distilled 50,000 words of knowledge into this little volume, all of which is dedicated to helping you write your best Swift code. I’ve tried to cover a wide range of topics so that everyone will find something of interest, which means you’ll find chapters on closures, chapters on functional programming, chapters on MVC, chapters on operator overloading, and more – it’s a real feast for developers who want to see what Swift is truly capable of.

I have to admit that it’s easy to slip into writing “Objective-C in Swift” when you’re an experienced Apple developer, at which point the language just seems like a bossy school teacher that enjoys pointing out your mistakes. But once you start writing idiomatic Swift –

Swift as it was meant to be written – suddenly you realize you have an elegant, efficient, and expressive language that will help you ship better software.

There is no right way to read Pro Swift. You can jump in at whatever chapter interests you if that’s what works, although I suspect you’ll find it easier just to start at the beginning and work your way through. I make no apologies for jumping around so many topics – I’ve tried to be as precise as possible while still giving you hands on examples you can try as you read. And please do try the examples!

One more thing: obviously I hope you enjoy all the chapters in the book, but there were a few that I particularly enjoyed writing and I hope you enjoy them as much while reading. They are “Labeled statements”, “Throwing functions as parameters”, “compactMap()”, and “Function composition” – have fun!

Frequent Flyer Club

You can buy Swift tutorials from anywhere, but I’m pleased, proud, and very grateful that you chose mine. I want to say thank you, and the best way I have of doing that is by giving you bonus content above and beyond what you paid for – you deserve it!

Every book contains a word that unlocks bonus content for Frequent Flyer Club members. The word for this book is CYCLONE. Enter that word, along with words from any other Hacking with Swift books, here:


This book is dedicated to my nephew John, who is right now taking his first steps in programming. He’s a smart kid with a lot of ideas, but most importantly he’s massively curious about the world around him. I hope one day not too far in the future this book will be useful to him too.


A number of people were kind enough to contribute to the creation of this book, and I’m most grateful. In particular, some really great developers took the time to write a short snippet to open each chapter of the book, giving you some fresh, practical insights from Swift developers I respect deeply. In alphabetical order they are Wayne Bishop, Chris Eidhof, Matt Gallagher, Simon Gladman, Wendy Lu, Andy Matuschak, Natasha Murashev, and Veronica Ray – thank you all!

I’m also grateful to Michael Mayer, who helps run the Philly CocoaHeads book club, for providing a second opinion on a chapter I was doubtful about. I ended up removing it from the

book – as much as I hate deleting work I’ve written, I would hate it even more if I was giving you something I thought wasn’t up to scratch.

In places I have used small amounts of source code from the official Swift open source project, mostly to illustrate specific techniques. This code is released under the Apache License v2.0 with the following header:

Copyright (c) 2014 - 2018 Apple Inc. and the Swift project
Licensed under Apache License v2.0 with Runtime Library
See for license information
See for the list of Swift
project authors

The Swift development team continue to do incredible work. My job – and yours! – would be very different without them, and it’s important we thank them for their continuing efforts. In particular, Joe Groff (@jckarter) seems to have more hours in the day than anyone else, and I’m grateful for all the times he’s answered my questions.

Get in touch

If you spot any typos or other mistakes, please email me at or tweet me @twostraws and I’ll do my best to correct them quickly.

Thank you for your support – I love programming in Swift, writing about Swift, and teaching others about Swift. Your support is what makes that possible, and it means a lot to me.

Pro Swift and Hacking with Swift are copyright Paul Hudson. All rights reserved. No part of this book or corresponding materials (such as text, images, or source code) may be reproduced or distributed by any means without prior written permission of the copyright owner.