why do we need that code?

  • (void)setEmployees:(NSMutableArray *)a
    for (Person *person in employees) {
    [self stopObservingPerson:person];

    employees = a;

    for (Person *person in employees) {
    [self startObservingPerson:person];


That’s because your are changing the value of the employees array, which might contain employees that are are not in the new array.
If there are such employees, you are no longer interested in them, so you stop observing them.


Thank you for your reply,
still didnt get 2 things:

  1. when this method get called?
  2. employees = a; what it do exactly?