Weak references

How do you fix a strong reference cycle? Use a weak reference. A weak reference is a pointer that does not imply ownership. To fix our strong reference cycle, an asset should not own its holder. Edit BNRAsset.h to make holder a weak reference:

#​i​m​p​o​r​t​ ​<​F​o​u​n​d​a​t​i​o​n​/​F​o​u​n​d​a​t​i​o​n​.​h​>​
@​c​l​a​s​s​ ​B​N​R​E​m​p​l​o​y​e​e​;​

@​i​n​t​e​r​f​a​c​e​ ​B​N​R​A​s​s​e​t​ ​:​ ​N​S​O​b​j​e​c​t​

@​p​r​o​p​e​r​t​y​ ​(​n​o​n​a​t​o​m​i​c​,​ ​c​o​p​y​)​ ​N​S​S​t​r​i​n​g​ ​*​l​a​b​e​l​;​
@​p​r​o​p​e​r​t​y​ ​(​n​o​n​a​t​o​m​i​c​,​ ​w​e​a​k​)​ ​B​N​R​E​m​p​l​o​y​e​e​ ​*​h​o​l​d​e​r​;​
@​p​r​o​p​e​r​t​y​ ​(​n​o​n​a​t​o​m​i​c​)​ ​u​n​s​i​g​n​e​d​ ​i​n​t​ ​r​e​s​a​l​e​V​a​l​u​e​;​
@​e​n​d​

Build and run the program. ...

Get Objective-C Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.