November 2016
Intermediate to advanced
480 pages
14h 42m
English
Unfortunately, Swift does not give you access to the actual reference count of any instances. (Although recall from Chapter 18 that you can ask if a variable is the only reference to an instance via the isKnownUniquelyReferenced(_:) function.)
Even if you could ask an instance what its reference count is, the answer you get might not be what you expect. Throughout this chapter, we said things like, “At this point, the reference count is 2.” That was a white lie.
Conceptually, it is perfectly reasonable for you to think of reference counts the way we described. Under the hood, the compiler is free to insert additional calls to retain (increment the reference count) ...
Read now
Unlock full access