Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5986783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:43:16+00:00 2026-05-22T22:43:16+00:00

This seems like a simple thing, but my brain doesn’t seem to be working

  • 0

This seems like a simple thing, but my brain doesn’t seem to be working today, and my searches haven’t turned up a helpful answer.

I have lots of code that extends Cocoa classes via categories (it’s open source, too). Some methods want to call the delegate; the old code used informal protocols to do this, but now when building targeting 10.6, I get the warning:

warning: '-outlineView:menuForTableColumn:byItem:' not found in protocol(s)

As an example, here’s a category:

@interface NSOutlineView (DSOutlineViewCategories)

- (NSMenu *)menuForEvent:(NSEvent *)event;

@end

Which used an informal protocol to declare a delegate method:

@interface NSObject (DSTableViewDelegate)

- (NSMenu *)outlineView:(NSOutlineView *)olv menuForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;

@end

And the implementation calls that on the delegate:

@implementation NSOutlineView (DSOutlineViewCategories)

- (NSMenu *)menuForEvent:(NSEvent *)event
{
    NSPoint point = [self convertPoint:[event locationInWindow] fromView:nil];
    NSInteger column = [self columnAtPoint:point];
    NSInteger row = [self rowAtPoint:point];
    id item = [self itemAtRow:row];

    if (column >= 0 && item && [[self delegate] respondsToSelector:@selector(outlineView:menuForTableColumn:byItem:)])
        return [[self delegate] outlineView:self menuForTableColumn:[[self tableColumns] objectAtIndex:column] byItem:item];
    else
        return [super menuForEvent:event];
}

@end

How can I update this code for 10.6 (and beyond), to avoid the “not found in protocol(s)” warning?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:43:17+00:00Added an answer on May 22, 2026 at 10:43 pm

    I think this is because the NSOutlineView delegate is now typed as id <NSOutlineViewDelegate> rather than a plain id as it was in the 10.5 SDK. The category is declared on NSObject, but the compiler doesn’t see the delegate object as inheriting from NSObject, so it doesn’t recognize that it would respond to the message. Before, since the delegate was a plain id, it wouldn’t complain about any message sent to it, as long as it could find the declaration somewhere.

    The quick and dirty fix would be to just add a cast, making the code [(id)[self delegate] outlineView:self menuForTableColumn:[[self tableColumns] objectAtIndex:column] byItem:item];

    To be a little more formal, you could declare your own formal delegate protocol which inherits from NSOutlineViewDelegate, which would look like

    @protocol DSOutlineViewDelegate <NSOutlineViewDelegate>
    
    @optional
    - (NSMenu *)outlineView:(NSOutlineView *)olv menuForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item;
    
    @end
    

    Then, in the code that calls it, you would want to be calling the method on an object with type id <DSOutlineViewDelegate>. You can do this by declaring a new method that does the casting for you, like:

    - (id <DSOutlineViewDelegate>)ds_delegate
    {
        return (id <DSOutlineViewDelegate>)[self delegate];
    }
    

    Then, in the actual code, you’d call:

    [[self ds_delegate] outlineView:self menuForTableColumn:[[self tableColumns] objectAtIndex:column] byItem:item];
    

    and the compiler should be OK with that. Since the method is declared as optional in the protocol, you still want to check at runtime whether the delegate actually responds to the selector.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this seems like very simple maths but somehow, my brain cant think ... i
This seems like a simple question, but I can't find it with the Stack
This seems like such a trivial problem, but I can't seem to pin how
This seems like a very simple and a very common problem. The simplest example
This sure seems like a simple error to fix. However, I somehow can't figure
This seems like a pretty softball question, but I always have a hard time
This seems like a silly question but I would really like your comments and
This seems like perhaps a naive question, but I got into a discussion with
It seems like this should be straightforward but I'm boggling. I've got my listview
How can I construct my ajaxSend call, this seems like the place to put

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.