ebook img

Head First Swift PDF

439 Pages·2021·49.141 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Head First Swift

Swift A Learner’s Guide to Programming with Swift Paris Buttfield-Addison & Jonathon Manning AA BBrraaiinn--FFrriieennddllyy GGuuiiddee .5” Other related books from O’Reilly iOS Swift Game Development Cookbook iOS 15 Programming Fundamentals with Swift Learning Swift Practical Artificial Intelligence with Swift Swift Pocket Reference Native Mobile Development Other books in O’Reilly’s Head First series Head First Android Development Head First C# Head First Design Patterns Head First Git Head First Go Head First iPhone and iPad Development Head First Java Head First JavaScript Programming Head First Learn to Code Head First Object-Oriented Analysis and Design Head First Programming Head First Python Head First Software Development Head First Web Design Head First Swift Wouldn’t it be dreamy to quickly learn Swift? I could build apps, websites, command- line tools...anything! Paris Buttfield-Addison Jonathon Manning Beijing Boston Farnham Sebastopol Tokyo Head First Swift by Paris Buttfield-Addison and Jonathon Manning Copyright © 2022 Secret Lab. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly Media books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://oreilly.com). For more information, contact our corporate/institutional sales department: (800) 998-9938 or [email protected]. Series Creators: Kathy Sierra, Bert Bates Acquisitions Editor: Suzanne McQuade Development Editor: Michele Cronin Cover Designer: Karen Montgomery Brain Image on Spine: Eric Freeman Production Editor: Christopher Faucher Proofreader: Rachel Head Indexer: Potomac Indexing, LLC Page Viewers: Mars Buttfield-Addison, Argos and Apollo (dogs). Printing History: November 2021: First Edition. The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. The Head First series designations, Head First Swift, and related trade dress are trademarks of O’Reilly Media, Inc. Head First Swift is an independent publication and has not been authorized, sponsored, or otherwise approved by Apple Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trademark claim, the designations have been printed in caps or initial caps. Apple, the Apple logo, iOS, iPadOS, macOS, Mac, Xcode, Swift Playgrounds, SwiftUI, watchOS, tvOS, iPad, iPhone, iPod, and iPod touch are trademarks of Apple Inc., registered in the U.S. and other countries. Swift and the Swift logo are trademarks of Apple Inc. Head First Swift is an independent publication and has not been authorized, sponsored, or otherwise approved by Apple Inc. While every precaution has been taken in the preparation of this book, the publisher and the authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. No parrots, robots, or chefs were harmed in the making of this book. ISBN: 978-1-491-92285-9 [LSI] [2021-11-17] Thanks to the Swift open source team, the folks at Apple, and all of the folks from the /dev/world conference and wider Swift community. And thanks to Swift, for being complex enough (and interesting enough!) to warrant this book. Oh, and thanks to our families. Paris particularly thanks his Mum, and his wife, and Jon thanks his Mum, Dad, and wildly extended family for all of their support. the authors Authors of Head First Swift Paris Buttfield-Addison Jon Manning Paris Buttfield-Addison and Jon Manning are the cofounders of Hobart, Tasmania, Australia–based video game development studio Secret Lab. Both Paris and Jon have PhDs in computer science, and between them they’ve written around 30 technical books over the years. They worked together at the influential “Web 2.0”–era startup Meebo, and are part of the team behind one of the longest-running Apple-related developer conferences, AUC /dev/world. Paris and Jon have worked on thousands of apps and games at Secret Lab. They’re best known for the adventure game Night in the Woods, which won an Independent Game Festival award and a BAFTA, as well as their popular open source project Yarn Spinner at https://yarnspinner.dev, which powers thousands of narrative video games. Paris and Jon both live and work in Hobart and enjoy photography, cooking, and giving far too many conference talks. Find Paris on Twitter @parisba and online at https://paris.id.au, Jon on Twitter @desplesda and online at https://desplesda.net, and Secret Lab on Twitter at @thesecretlab and online at https://secretlab.games . Secret Lab vi table of contents Table of Contents (the summary) intro xxi 1 introducing swift: Apps, Systems, and Beyond! 1 2 swift by name: Swift by Nature 29 3 collecting and controlling: Going Loopy for Data 55 4 functions and enums: Reusing Code on Demand 97 5 closures: Fancy, Flexible Functions 133 6 structures, properties, and methods: Custom Types and Beyond 161 7 classes, actors, and inheritance: Inheritance is Always a Thing 193 8 protocols and extensions: A Swift Lesson in Protocol 219 9 optionals, unwrapping, generics, and more: Nothing Optional About It 253 10 getting started with swiftUI: User Interfaces...Swiftly 281 11 putting swiftUI into practice: Circles, Timers, Buttons—Oh My! 327 12 apps, web, and beyond: Putting It All Together 357 index 397 Table of Contents (the real thing) Intro Your brain on Swift. Here you are trying to learn something, while here your brain is doing you a favor by making sure the learning doesn’t stick. Your brain’s thinking, “Better leave room for more important things, like which wild animals to avoid and whether naked snowboarding is a bad idea.” So how do you trick your brain into thinking that your life depends on knowing Swift? Who is this book for? xxii We know what you’re thinking xxiii We know what your brain is thinking xxiii Metacognition: thinking about thinking xxv Here’s what WE did xxvi Here’s what YOU can do to bend your brain into submission xxvii Read me xxviii The technical review team xxx Acknowledgments xxxi vii table of contents introducing swift Apps, Systems, and Beyond! 1 Swift is a programming language you can rely on. It’s a programming language you can take home to meet your family. Safe, reliable, speedy, friendly, easy to talk to. And while Swift is best known for being the programming language of choice for Apple’s platforms, such as iOS, macOS, watchOS, and tvOS, the open source Swift project also runs on Linux and Windows, and is gaining ground as a systems programming language, as well as on the server. You can build everything from mobile apps, to games, to web apps, to frameworks and beyond. Let’s get started! Swift Swift is a language for everything 2 The swift evolution of Swift 4 Swift into the future 5 How you’re going to write Swift 6 The path you’ll be taking 8 Getting Playgrounds 9 Creating a Playground 11 Using a Playground to code Swift 12 Basic building blocks 14 A Swift example 20 Congrats on your first steps with Swift! 25 viii

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.