Why not __weak for all?


I tried to mark all BNRItem attributes as __weak and everything seems to work. So why not mark them all by default as weak and be free of thinking about cyclic references? Some performance penalty? Is is really that bad?



Ah, sorry, actually it does not work.
XCode warns with “Assigning retained object to weak variable; object will be released after assignment” - and it really is released, when I e.g. create a new BNRItem with its inst. vars. set, after printing the object all its attributes are (null).

So seems __weak can be used only if the object is referenced to by another strong reference.


Weak is pretty much only used to break retain cycles. An object only exists if it has at least one strong reference, so if it only has one weak reference, it won’t exist.