On Mar 25, 2013, at 7:33 PM, Conrad Shultz <conrad_shu...@apple.com> wrote:
> In the code you shared you had used "delegate" in one place and "[self > delegate]" in another; the second case is the correct one. If you replace all > naked uses of "delegate" with "[self delegate]" and you continue to get > compile-time errors please post your entire class or a reduced test case. Okay, I am realizing that my original post was misleading about what the main issue is. The main point I should have made is that [self delegate] is not being allowed to handle my custom delegate methods. It is expecting a method from NSOutlineViewDelegate. The error I am getting is.... No known instance method for selector 'outlineView:enterKetPressedForRow:' Can I make a category on NSOutlineViewDelegate? Here's my original code with corrected [self delegate] -------------------------------------------------------------------- HEADER -------------------------------------------------------------------- #import <Cocoa/Cocoa.h> @class TKOutlineView; // lets compiler know the @interface deleration is coming since we put @protocol before it // delegate protocol @protocol TKOutlineViewDelegate <NSObject> // <NSObject> because we need to use "respondsToSelector" @optional -(void)outlineView:(NSOutlineView *)theOutlineView enterKeyPressedForRow:(NSInteger)theRow; -(void)outlineView:(NSOutlineView *)theOutlineView deleteKeyPressedForRow:(NSInteger)theRow; @end @interface TKOutlineView : NSOutlineView {} @end -------------------------------------------------------------------- IMPLEMENTATION -------------------------------------------------------------------- #import "TKOutlineView.h" @implementation TKOutlineView -(void)keyDown:(NSEvent *)theEvent { if ([[theEvent characters] length] == 0) { // dead key return; } else if ([[theEvent characters] length] == 1 && [[theEvent characters] characterAtIndex:0] == NSEnterCharacter && [[self delegate] respondsToSelector:@selector(outlineView: enterKeyPressedForRow:)]) { [[self delegate] outlineView:self enterKeyPressedForRow:[self selectedRow]]; /* ERROR THIS LINE */ } else if ([[theEvent characters] length] == 1 && [[theEvent characters] characterAtIndex:0] == NSDeleteCharacter && [[self delegate] respondsToSelector:@selector(outlineView: deleteKeyPressedForRow:)]) { [[self delegate] outlineView:self deleteKeyPressedForRow:[self selectedRow]]; /* ERROR THIS LINE */ } else { [super keyDown:theEvent]; } } @end How can I get [self delegate] to recognize my custom methods? CT _______________________________________________ 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