• 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
Rép : Enabled Binding and Array Controllers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Rép : Enabled Binding and Array Controllers


  • Subject: Rép : Enabled Binding and Array Controllers
  • From: Pierre Molinaro <email@hidden>
  • Date: Fri, 8 Feb 2008 10:44:15 +0100

I think you can bind to canRemove controller key, leaving model key path empty.

Bind to: ArrayController
Controller Key: canRemove
Model Key Path:  (empty)

Oops, I realize that the above code works only if "Avoid Empty Selection" array controller option is set.


I suggest the following code : subclass NSArrayController, observe "arrangedObjects" property, and manually trigger change of a "isNotEmpty" boolean attribute.

@interface MyArrayController : NSArrayController {
}
@end

@implementation MyArrayController

- (void) didChangeValueForKey: (NSString *) inKey {
 [super didChangeValueForKey:inKey] ;
 if ([inKey isEqualToString:@"arrangedObjects"]) {
   [self willChangeValueForKey:@"isNotEmpty"] ;
   [self  didChangeValueForKey:@"isNotEmpty"] ;
 }
}

- (BOOL) isNotEmpty {
 return [[self arrangedObjects] count] > 0 ;
}
@end

In interface builder, set array controller class to MyArrayController; For enabled binding :
Bind to: ArrayController
Controller Key: isNotEmpty
Model Key Path: (empty)


Pierre

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Using iChat Theater
  • Next by Date: Re: How to detect focus on an NSTextField
  • Previous by thread: Re: Using iChat Theater
  • Next by thread: problem closing file handle
  • Index(es):
    • Date
    • Thread