Undo invocations not firing


I’m working through Chapter 9 (enjoying the book!) and have come a little undone.

The methods on page 151 don’t appear to fire when I add or remove a user. I’ve gone back through and checked I did every step correctly, and all seems well. Is there something I’m likely to have done wrong?

I wondered if it was something to do with the action of the add and remove buttons. On page 137 we set the actions to add: and remove: respectively, but on page 152 you refer to them as insert: and remove:. Having said that, I changed the add button’s action to insert: and it made no difference.

The funny thing is: after fighting with this for a while I pushed on through adding edit undo and redo. That works!

I apologise if that was all far too vague. Let me know if you need any more info.

Thanks in advance for the help and for such a useful book!



Regarding -insertObject:inEmployeesAtIndex: and -removeObjectFromEmployeesAtIndex: not being called, I would suggest triple-checking the spelling and capitalization of those methods. Also, did you take any liberties with the naming of the employees property? If the method and key names do not match up perfectly then they will not be called.

add: or insert: should both work fine, although they behave somewhat differently as far as where the new object is created. Does adding and removing work fine, the insert/remove KVC methods just aren’t being called?

Glad to hear you’re enjoying the book!



Thanks for the advice. Despite all my checking I’m embarrassed to admit I had -removeObjectFromEmployeesAtIndex: as -removeObjectFromExmployeesAtIndex: It can be a bit like counting the Fs or spotting a double ‘the’. As nice as Xcode’s autocomplete is, if I declare something wrong in a header file then the mistake gets everywhere.

Thanks again for the swift reply, now on with the rest of the book!