Re: Custom canRemove binding
Re: Custom canRemove binding
- Subject: Re: Custom canRemove binding
- From: ian <email@hidden>
- Date: Wed, 5 May 2004 15:54:12 +0100
On 5 May 2004, at 15:22, Allan Odgaard wrote:
On 5. May 2004, at 14:26, ian wrote:
I'd like to prevent the user from deleting the last row in the table
however, so I bound the remove button to File's Owner (MyDocument)
and a model key path of "myCanDelete" which is the name of a method
that returns ([theArray count]>1)
Trouble is, this is called once only at startup, so the button
doesn't update.
And here's the third suggestion! :)
Given that 'contentArray' of your array controller is bound to [File's
Owner].myArray then add this to MyDocument.m (see NSKeyValueObserving
protocol description for details):
+ (void)initialize
{
[self setKeys:[NSArray arrayWithObject:@"myArray"]
triggerChangeNotificationsForDependentKey:@"myCanDelete"];
}
Crikey, that's smooth, very elegant. Now the whole validation thing
happens automagically without explicitly informing observers that
something interesting happened.
Cool :)
Ian
_______________________________________________
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.