SwiftUI ™ For Dummies®
Published by: John Wiley & Sons, Inc.,111 River Street, Hoboken, NJ 07030-5774, www.wiley.com
Copyright © 2020 by John Wiley & Sons, Inc., Hoboken, New Jersey
Published simultaneously in Canada
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without the prior written permission of the Publisher. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions
.
Trademarks:Wiley, For Dummies, the Dummies Man logo, Dummies.com, Making Everything Easier, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and may not be used without written permission. SwiftUI is a trademark of Apple, Inc. All other trademarks are the property of their respective owners. John Wiley & Sons, Inc. is not associated with any product or vendor mentioned in this book. SwiftUI ™For Dummies ®is an independent publication and has not been authorized, sponsored, or otherwise approved by Apple, Inc.
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ.
For general information on our other products and services, please contact our Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002. For technical support, please visit https://hub.wiley.com/community/support/dummies
.
Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such as a CD or DVD that is not included in the version you purchased, you may download this material at http://booksupport.wiley.com
. For more information about Wiley products, visit www.wiley.com
.
Library of Congress Control Number: 2020939546
ISBN 978-1-119-65268-7 (pbk); ISBN 978-1-119-65272-4 (ebk); ISBN 978-1-119-65270-0 (ebk)
SwiftUI™ For Dummies®
To view this book's Cheat Sheet, simply go to www.dummies.comand search for “Swift UI For Dummies Cheat Sheet” in the Search box.
Table of Contents
1 Cover
2 Introduction Introduction In 2019, at the Apple Worldwide Developers Conference, Apple announced SwiftUI, a declarative programming framework for developing user interfaces (UIs) for iOS and macOS applications. With SwiftUI, Apple aims to modernize the iOS development experience. There’s no doubt that SwiftUI makes it much easier and more efficient for developers to create apps, but it also means you have to learn something new. That’s where SwiftUI For Dummies comes in. This book provides you with all the essentials that you need to learn to become a successful iOS developer using SwiftUI.
About This Book About This Book This book covers the basics of SwiftUI. Because SwiftUI supports iOS, iPadOS, macOS, watchOS, and tvOS, it’s a really big topic. To narrow the scope, this book focuses on using SwiftUI with iOS, specifically to program iPhone apps. In this code-intensive book, you’re encouraged to try out the examples in each chapter. The chapters are designed to be compact, easy to follow, and easy to understand. However, you don’t have to read this book from the first page to the last. Each chapter is designed to be independent, and you’re free to start with any chapter to find the topic that you’re interested in. I don’t use many special conventions, but here are a couple points you should be aware of: Sidebars (text in gray boxes) and anything marked with the Technical Stuff icon are skippable, and code appears in monofont . Pretty simple, right? Finally, within this book, you may note that some web addresses break across two lines of text. If you're reading this book in print and want to visit one of these web pages, simply key in the web address exactly as it’s noted in the text, pretending as though the line break doesn’t exist. If you’re reading this as an e-book, you’ve got it easy — just click the web address to be taken directly to the web page.
Foolish Assumptions Foolish Assumptions This book is for people who are new (or relatively new) to using SwiftUI for iOS development. Though I do not assume that you’re familiar with iOS programming, I do assume the following: You’re familiar with the basics of programming. You’re familiar with how an iPhone works. You have a Mac that you can use to try out the examples in this book. You don’t need an iPhone to test the applications in this book (except for Chapter 12 where I show you how to load your iPhone with the application you’ve built); the iPhone Simulator will suffice. Some chapters in this book assume that you’re familiar with UIKit programming (the framework used for iOS programming prior to SwiftUI). But this knowledge is not a prerequisite for using this book.
Icons Used in This Book Icons Used in This Book Like other books in the For Dummies series, this book uses icons, or little pictures in the margins, to draw your attention to certain kinds of material. Here are the icons that I use: Whenever I tell you something useful or important enough that you’d do well to store the information somewhere safe in your memory for later recall, I flag it with the Remember icon. The Technical Stuff icon marks text that contains some for-nerds-only technical details or explanations that you’re free to skip. The Tip icon marks shortcuts or easier ways to do things, which I hope will make your life easier. The Warning icon marks text that contains a friendly but unusually insistent reminder to avoid doing something. You have been warned.
Beyond the Book Beyond the Book In addition to what you’re reading right now, this product comes with a free access-anywhere Cheat Sheet that includes information on creating a stacked and table navigation app, creating shake fail feedback using animation, and more. To get this Cheat Sheet, go to www.dummies.com and type SwiftUI For Dummies Cheat Sheet in the Search box. This book includes some downloadable content as well — all the code in the book, as well as the files you need to create the app described in the book. Go to www.dummies.com/go/swiftuifd to download all this great stuff.
Читать дальше