-(id)newObject -> How does it get called


I’m trying to figure out how -(id)newObject is getting called.
We have linked the Add button to Cars add: but that’s it.

If I add “-(void)add:(id)sender” to carArrayController then “-(id)newObject” does not get called.
This tell me there is some sort of hierarchy calling system but I cant find information on the subject.

Could some one enlighten me?


I’ve searched, read the documents and I still can not find the answer. The truth has to be out there!

In this chapter we target the Add button to the carArrayController add: method and thats it.
How the hell does NSArrayController add: method know it has to call -newObject if it is present.
We did not override add: to call -newObject.

This has to be some sort of hierarchy calling system but it is not documented nor is it explained in this book.

I need to know where to find this information in the documentation so I know what to look for in the future.


This answer comes from deduction.

To figure it out ou have to figure out, on your own, how Apple decided to build the documents and understanding the programming lingo but mostly the logic behind the documents structure!
And even then it’s not explicitly written, it’s logical deduction and trial end error.
So In my case I wanted to know how -newObject got called. Remember that the target of the Add button is Cars -add:.
Cars inherits from NSArrayController.
NSArrayController has the method add:. There is not much in it’s documentation.
NSArrayController inherits from NSObjectController and it also has the method add:.
In it’s documentation it mentions “see -newObject”. This is the only location in the document that kind of links -add: to -newObject.

As a side note, the second you subclass -add:, -newObject no longer gets called.