Re: Confused with Chapter 7 in Hillegass' book (2nd ed.)
Re: Confused with Chapter 7 in Hillegass' book (2nd ed.)
- Subject: Re: Confused with Chapter 7 in Hillegass' book (2nd ed.)
- From: Shalev NessAiver <email@hidden>
- Date: Wed, 28 Jul 2004 19:56:30 -0400
[Oooops, new as I am to this list, I hit Reply and sent the message
only to the poster and not to the whole list].
The NSArrayController object is used in conjunction with Cocoa
bindings. When the NSArrayController is bound to a specific property of
an object, it can both access and set the data that it is bound to. The
way it does this is by calling two methods in the class that
NSArrayController is bound to: (your class must implement these
methods)
Assume that the property in question is:
NSArray * employees;
The NSArrayController will then call the following method when it wants
to access the data:
- (NSMutableArray *)employees
{
return employees;
}
To set the data (ie. when a view element makes changes to it) it calls
the method:
- (void)setEmployees:(NSArray *)newEmployees
{
[employees autorelease];
employees = [newEmployees copy];
}
If there is some sort of example code (I don't have the book) look at
the NSArrayController's "Bindings" pane in Interface Builder. It should
show the bindings.
All of this is just a guess - I recently "discovered" bindings myself
and what you described seemed to fit perfectly.
-Shalev
On Jul 28, 2004, at 6:52 PM, Steven Harms wrote:
>
I'm particularly baffled about the mention of setEmployees: under the
>
heading "adding undo to raiseman". Why is this function here? I
>
think it's so that the NSArrayController can talk to MyDocument -- but
>
what calls it? I understand the retain and release etc. -- but when
>
is this called, by what, is this part of the default behavior of
>
NSArrayController?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.