Set containedItem in setContainer method?


When implementing both setter methods, in setContainedItem, we are setting the container of item to self like this:

[code]- (void)setContainedItem:(BNRItem *)item {
_containedItem = item;

item.container = self;


Why aren’t we doing the same thing in setContainer similar to this:

[code]- (void)setContainer:(BNRItem *)item {
_container = item;

item.containedItem = self;


This seams so simple but I don’t understand why it’s not working


It does not work since the code leads to infinite loop; backpack calls ‘setContainedItem’ with calc and inside of it item.container calls setContainer of calc, inside of it item.containedItem calls setContainer of backpack,and so on.