On Apr 16, 2012, at 16:18 , Koen van der Drift wrote:

> Still a bit confused here. My tableview from which I want to delete
> items is controlled by an NSViewController, and populated by an
> NSArrayController that is again hooked up to my CoreData model.

Yes, that's an awkward case. Although a NSViewController *is* a responder, it 
*isn't* automatically added to the responder chain. Therefore it cannot be 
found as first responder, and so its action method is not recognized by menu 
validation. :)

You can manually add the view controller to the responder chain if you want, in 
loadView perhaps. However, I've never quite figured out all the places where 
I'd need to manually remove it again. (If you're not swapping views, then maybe 
you don't need to worry about that -- just leave it there until the responder 
chain gets pruned in the normal course of events.)

Otherwise, you have to move the validation code to the window controller (or 
whatever object can receive the validation request), *and* put a duplicate 
'delete:' action method in the window controller, *and* have it call the view 
controller's 'delete:' method.

Another alternative might be to implement 'delete:' in the view itself (if you 
can use/are using a custom view subclass), and delegate both the validation and 
the invocation to the view controller.

Sorry, I don't know of a cleaner way. Maybe someone else will jump in with an 
improved solution.


_______________________________________________

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

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

Reply via email to