Magic method calls in NSArrayController
Magic method calls in NSArrayController
- Subject: Magic method calls in NSArrayController
- From: "Roger deBry" <email@hidden>
- Date: Wed, 02 Feb 2005 11:01:56 -0700
In Hillegass's book on Cocoa Programming, he shows some sample code for
using NSUndoManager. In this example, he has an NSDocument class that
contains a pointer to an array of Person Objects. The name of the
array
pointer is "employees".
He has set up an NSArrayController whose content array is bound to
"employees" in the Document class.
A "Create New" button is connected to the NSArrayController's "insert"
action. He has written the following method in his Document class:
- (void) insertObject:(Person *)p inEmployeesAtIndex:(int)index;
In his book he simply says that this method will be called
automatically when the NSArrayController wishes to insert a Person
object into the array.
I wrote the code and indeed this works. However, I have no idea why,
and so I am not sure that I could re-create this behavior in my own
programs. It appears to have something to do with the method
selector.
If I change any of it, for example
- (void) insertBob:(Person *)p inEmployeesAtIndex:(int)index;
the method does not get called.
Can anyone explain the magic here?
Thank you kindly.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden