Swift Cookbook - Keith Moon - E-Book

Swift Cookbook E-Book

Keith Moon

0,0
28,79 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Unlock the full potential of Swift and elevate your iOS development skills with this new edition of Swift Cookbook, highlighting the latest features in Swift 5.9.
This cookbook will take your Swift programming skills to the next level, boosting your productivity and efficiency step by step through a plethora of practical recipes. Although this book is primarily for experienced iOS developers, it provides an introductory overview of Swift 5.9, including its basic building blocks, syntax, and the functionalities of Swift constructs, to get you warmed up. Once you’ve mastered the fundamentals, you’ll get down to business.
Unless you’re completely new to Swift, this recipe-based guide doesn’t need to be read in order; you can jump to whichever topic takes your fancy, from UIKit and SwiftUI to advanced UI techniques, from Swift’s control flow and generics to machine learning with Vision, CoreML, and augmented reality with ARKit.
By the end of this book, you’ll be fully up to speed with Swift’s capabilities and be able to develop amazing applications across a wide variety of domains.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 440

Veröffentlichungsjahr: 2024

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Swift Cookbook

Proven recipes for developing robust iOS applications with Swift 5.9

Keith Moon

Chris Barker

Daniel Bolella

Nathan Lawlor

Swift Cookbook

Copyright © 2024 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

Group Product Manager: Rohit Rajkumar

Publishing Product Manager: Nitin Nainani

Book Project Manager: Aishwarya Mohan

Senior Editor: Mudita S

Technical Editor: Reenish Kulshrestha

Copy Editor: Safis Editing

Proofreader: Mudita S

Indexer: Manju Arasan

Production Designer: Alishon Mendonca

DevRel Marketing Coordinators: Anamika Singh and Nivedita Pandey

First published: April 2015

Second edition: February 2021

Third edition: May 2024

Production reference: 1030524

Published by Packt Publishing Ltd.

Grosvenor House

11 St Paul’s Square

Birmingham

B3 1RB, UK.

ISBN 978-1-80323-958-3

www.packtpub.com

To my wife and children, for their love, support, and inspiration. I love you all more than words can ever capture.

– Danny Bolella

I would like to thank my mother, Sofia, and my father, Graham, for their continuous support throughout my career and personal projects. Without them, I would not be where I am today.

– Nathan Lawlor

Contributors

About the authors

Keith Moon is an award-winning iOS developer, author, and speaker based in London. He has worked with some of the biggest companies in the world to create engaging and personal mobile experiences. Keith has been developing in Swift since its release, working on projects that are both fully Swift and mixed Swift and Objective-C. Keith has been invited to speak about Swift development at conferences from Moscow to Minsk and London.

Chris Barker is a Principal Software Engineer at Jaguar Land Rover, where he leads the Mobile Application Engineering Team across the business. With over 22 years of experience in the IT industry, Chris began his career developing .NET applications for the online retailer dabs.com (now BT Shop).

In 2014, Chris transitioned into mobile app development. Before joining Jaguar Land Rover, he worked on mobile apps for clients such as Louis Vuitton, L'Oréal Paris, SimplyBe, JD Williams, and Jacamo.

Chris is the co-host of NS Manchester, a local iOS developer meet-up in Manchester, UK. He has been involved in authoring, co-authoring, and reviewing books for Packt Publishing since 2020.

Daniel Bolella is a lead iOS engineer at a major financial services firm. With over a decade of experience under his belt, he’s worked on everything from full stack web to mobile apps in a variety of industries, including financial, energy, and medical devices. He also enjoys writing articles and was the technical reviewer for the first and second editions of SwiftUI Cookbook.

Danny thanks his amazing wife and children, who give him the love, motivation, and drive to always be better. He thanks his parents, who lovingly encourage him to pursue his passions. He gives thanks to God, for always providing love and guidance. Lastly, he thanks all who have invested and mentored him, culminating in all he has become and achieved thus far.

Nathan Lawlor is a highly skilled iOS developer with many years of experience, initially starting his career as an apprentice in web development. Nathan has worked as a professional software developer in the home and fashion retail industry, with N Brown Group plc., and is now working in the automotive industry, with Jaguar Land Rover. He has published his own independent apps to the Apple App Store and regularly posts articles on his blog. Nathan has a passion for exploring new technologies and finding ways to improve code quality and best practices.

About the reviewers

Juan C. Catalan is a software engineer with more than 18 years of professional experience. He started mobile app development back in the days of iOS 3. Juan has worked as a professional iOS developer in many industries, including medical devices, financial services, real estate, document management, fleet tracking, and industrial automation. He has contributed to more than 30 published apps in the App Store, some of them with millions of users. Juan gives back to the iOS development community with technical talks, mentoring developers, and reviewing and authoring technical books. He is the author of SwiftUI Cookbook, Third Edition (Packt Publishing, 2023). Juan lives in Austin, Texas, with his wife Donna, where they spend time with their kids.

George MacKay-Shore is the lead engineer at AND Digital’s Club Spärck in Halifax, UK, with over a decade of experience in the embedded systems, games, and enterprise software sectors, in both the public and private sector, and mobile, desktop, and web application spaces.

He is also an aspiring archer, a part-time comedian, and an avid walker, and when he’s not reviewing books, he can be found learning new languages in the hope that he may one day use them!

Table of Contents

Preface

1

Swift Fundamentals

Technical requirements

Writing your first code in Swift

Getting ready

How to do it…

There’s more…

See also

Using the basic types – strings, ints, floats, and booleans

Getting ready

How to do it…

How it works…

There’s more…

See also

Reusing code in functions

Getting ready

How to do it…

There’s more…

See also

Encapsulating functionality in object classes

Getting ready

How to do it…

How it works…

There’s more…

See also

Bundling values into structs

Getting ready

How to do it…

How it works…

There’s more…

See also

Enumerating values with enums

Getting ready

How to do it…

How it works…

There’s more…

See also

Passing around functionality with closures

Getting ready

How to do it…

How it works…

There’s more…

See also

Using protocols to define interfaces

Getting ready

How to do it…

How it works…

There’s more…

See also

2

Mastering the Building Blocks

Technical requirements

Bundling variables into tuples

Getting ready

How to do it...

How it works...

There’s more...

See also

Ordering your data with arrays

Getting ready

How to do it...

How it works...

There’s more...

See also

Containing your data in sets

Getting ready

How to do it...

How it works...

See also

Storing key-value pairs with dictionaries

Getting ready

How to do it...

How it works...

There’s more...

See also

Subscripts for custom types

Getting ready

How to do it...

How it works...

There’s more...

See also

Changing your name with a type alias

Getting ready

How to do it...

There’s more...

See also

Getting property changing notifications using property observers

Getting ready

How to do it...

How it works...

There’s more...

See also

Extending functionality with extensions

Getting ready

How to do it...

How it works...

There’s more...

See also

Controlling access with access control

Getting ready

How to do it...

How it works...

There’s more...

See also

3

Data Wrangling with Swift

Technical requirements

Making decisions with if/else

Getting ready

How to do it...

How it works...

There’s more...

See also

Handling all cases with switch

Getting ready

How to do it...

How it works...

See also

Looping with for loops

Getting ready

How to do it...

How it works...

See also

Looping with while loops

Getting ready

How to do it...

How it works...

There’s more...

See also

Handling errors with try, throw, do, and catch

Getting ready

How to do it...

How it works...

There’s more...

See also

Checking upfront with guard

Getting ready

How to do it...

How it works...

There’s more...

See also

Doing it later with defer

Getting ready

How to do it...

How it works...

There’s more...

See also

Bailing out with fatalError and precondition

Getting ready

How to do it...

How it works...

See also

4

Generics, Operators, and Nested Types

Technical requirements

Using generics with types

Getting ready

How to do it...

How it works...

There’s more...

See also

Using generics with functions

Getting ready

How to do it...

How it works...

There’s more...

See also

Using generics with protocols

Getting ready

How to do it...

How it works...

There’s more...

See also

Using advanced operators

Getting ready

How to do it...

See also

Defining option sets

Getting ready

How to do it...

How it works...

See also

Creating custom operators

Getting ready

How to do it...

How it works...

There’s more...

See also

Nesting types and namespacing

Getting ready

How to do it...

How it works...

There’s more...

See also

5

Beyond the Standard Library

Technical requirements

Comparing dates with Foundation

Getting ready

How to do it…

How it works…

See also

Fetching data with URLSession

Getting ready

How to do it…

How it works…

See also

Working with JSON

Getting ready

How to do it...

There’s more...

Working with XML

Getting ready

How to do it...

How it works...

There’s more...

See also

6

Understanding Concurrency in Swift

Technical requirements

Getting ready

How to do it...

How it works...

See also

Leveraging DispatchGroups

Getting ready

How to do it...

How it works...

See also

Implementing the operation class

Getting ready

How to do it...

How it works...

See also

Async/Await in Swift

Getting ready

How to do it...

How it works...

See also

7

Building iOS Apps with UIKit

Technical requirements

Building an iOS app using UIKit and storyboards

Getting ready

How to do it...

How it works...

There’s more...

See also

Unit and integration testing with XCTest

Getting ready

How to do it...

How it works...

There’s more...

See also

UI testing with XCUITest

Getting ready

How to do it...

There’s more...

See also

8

Building iOS Apps with SwiftUI

Technical requirements

Declarative syntax

Getting ready

How to do it…

How it works...

There’s more...

See also

Function builders, property wrappers, and opaque return types

Getting ready

How to do it…

There’s more...

See also

Building simple views in SwiftUI

Getting ready

How to do it...

How it works...

There’s more...

See also

Combine and data flow in SwiftUI

Getting ready

How to do it...

How it works...

See also

9

Getting to Grips with Combine

Technical requirements

Using Reactive Streams

Getting ready

How to do it...

How it works...

See also

Understanding Observable Objects

How to do it...

How it works...

See also

Understanding publishers and subscribers

How to do it...

How it works...

See also

Combine versus Delegate pattern

How to do it...

How it works...

10

Using CoreML and Vision in Swift

Technical requirements

Getting ready

How to do it...

How it works...

There’s more...

See also

Using CoreML models to detect objects in images

Getting ready

How to do it...

How it works...

There’s more...

See also

Building a video capture app

Getting ready

How to do it...

How it works...

There’s more...

See also

Using CoreML and the Vision framework to detect objects in real time

Getting ready

How to do it...

How it works...

See also

11

Immersive Swift with ARKit and Augmented Reality

Technical requirements

Surface detection with ARKit

Getting ready

How to do it...

How it works...

There’s more…

See also

Using 3D models with ARKit

Getting ready

How to do it…

How it works...

There’s more…

Using Reality Composer Pro for visionOS

Getting ready

How to do it...

How it works...

There’s more…

See also

12

Visualizing Data with Swift Charts

Technical requirements

Building a chart with data

Getting ready

How to do it…

How it works...

See also

Displaying multiple datasets

How to do it...

How it works...

Exploring chart marks and modifiers

How to do it...

How it works...

There’s more...

Index

Other Books You May Enjoy