On 29 Jul 2009, at 06:09, Alexander Heinz wrote:

Hello all,

I've got an NSArrayController subclass with a computed property:

@property (readonly) BOOL canRemoveSelection;

(This basically adds some application-specific checks to the canRemove: property, so that I can bind a "remove" button in Interface Builder.)

I want the property to be recomputed every time the "selectionIndex" or "selectionIndexes" of the array controller change, so, in my ".m" file, I have:

+ (NSSet*)keyPathsForValuesAffectingCanRemoveSelection
{
return [NSSet setWithObjects:@"selectionIndex", @"selectionIndexes", nil];
}

(I realize this is probably redundant, but bear with me.)

However, the accessor for the property (i.e., "- (BOOL) canRemoveSelection") is never called, beyond the initial call when the object is created. As a result, the button bound to the property never changes state.

I've checked to make sure that -setSelectionIndexes: is being called, and it is, but the property is not re-computed.

Does anyone see anything immediately wrong here?

Further to the other suggestions, have you checked in the debugger that your -keyPathsForValuesAffectingCanRemoveSelection is being called? It might be that NSArrayController overrides - keyPathsForValuesAffectingKey: to not call custom methods like yours.

Mike.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to