Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Learning Swift
  • Table Of Contents Toc
Learning Swift

Learning Swift

By : Andrew J Wagner
4.8 (5)
close
close
Learning Swift

Learning Swift

4.8 (5)
By: Andrew J Wagner

Overview of this book

If you are looking to build iOS or OS X apps using the most modern technology, this book is ideal for you. You will find this book especially useful if you are new to programming or if you have yet to develop for iOS or OS X.
Table of Contents (13 chapters)
close
close
12
Index

Lost objects


It is a great idea to always keep strong reference cycles in mind, but if we are too aggressive with the use of weak and unowned references, we can run into the opposite type of problem, where an object is deleted before we intend to delete it.

Between objects

With an object, this will happen if all the references to the object are weak or unowned. This won't be a fatal mistake if we use weak references, but if this happens with an unowned reference, it will crash your program.

For example, let's look at our earlier example with an extra weak reference:

class SteeringWheel3 {
    weak var car: Car3?
}

class Car3 {
    weak var steeringWheel: SteeringWheel3?
    
    init(steeringWheel: SteeringWheel3) {
        self.steeringWheel = steeringWheel
        self.steeringWheel!.car = self
    }
}

let wheel3 = SteeringWheel3()
let car3 = Car3(steeringWheel: wheel3)

This code is the same as the previous, except that both the car property of SteeringWheel3 and the steeringWheel property...

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.
Learning Swift
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon