• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Custom canRemove binding
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Follow-Ups:
    • Re: Custom canRemove binding
      • From: Scott Anguish <email@hidden>
References: 
 >Custom canRemove binding (From: ian <email@hidden>)
 >Re: Custom canRemove binding (From: Allan Odgaard <email@hidden>)

  • Prev by Date: Refreshing subviews
  • Next by Date: Re: Objective-C question
  • Previous by thread: Re: Custom canRemove binding
  • Next by thread: Re: Custom canRemove binding
  • Index(es):
    • Date
    • Thread