Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Mastering Swift 6

You're reading from   Mastering Swift 6 Modern programming techniques for high-performance apps in Swift 6.2

Arrow left icon
Product type Paperback
Published in Aug 2025
Publisher Packt
ISBN-13 9781836203698
Length 378 pages
Edition 7th Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Jon Hoffman Jon Hoffman
Author Profile Icon Jon Hoffman
Jon Hoffman
Arrow right icon
View More author details
Toc

Table of Contents (25) Chapters Close

Preface 1. The Evolution of Swift FREE CHAPTER 2. Closures and Result Builders 3. Protocols and Protocol Extensions 4. Generics 5. Value and Reference Types 6. Enumerations 7. Reflection 8. Error Handling and Availability 9. Regular Expressions 10. Custom Subscripting 11. Property Observers and Wrappers 12. Dynamic Member Lookup and Key Paths 13. Grand Central Dispatch 14. Structured Concurrency 15. Memory Management 16. Advanced and Custom Operators 17. Access Controls 18. Swift Testing 19. Object-Oriented Programming 20. Protocol-Oriented Programming 21. Functional Programming with Swift 22. Unlock Your Book’s Exclusive Benefits 23. Other Books You May Enjoy
24. Index

Summary

To handle the complexities of memory management for reference types such as classes, Swift employs Automatic Reference Counting (ARC). ARC tracks the number of references to each instance, automatically releasing the allocated memory when an instance is no longer needed. This prevents memory leaks and keeps our application performance at its best. However, developers must be aware of strong reference cycles, where objects hold strong references to each other, preventing ARC from deallocating them and causing memory leaks.

Swift provides mechanisms like weak and unowned references to break strong reference cycles. Weak references enable the referenced object to be deallocated, while unowned references assume the object will always be in memory. By properly using these references, developers can ensure their applications are efficiently managing memory and do not have memory leaks.

In the next chapter, we will look at access controls in Swift.

lock icon The rest of the chapter is locked
Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Mastering Swift 6
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime
Modal Close icon
Modal Close icon