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 4614776
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:44:50+00:00 2026-05-22T01:44:50+00:00

(I found some questions discussing the idea, but I didn’t see a solution for

  • 0

(I found some questions discussing the idea, but I didn’t see a solution for my problem.)

I added this convenience method as a category to NSObject. (I’ve added other methods, so I’m still interested in an answer even if you disagree with this particular convenience method.)

@implementation NSObject (MyCategory)
- (void)performInvocationOnMainThread:(NSInvocation *)invocation waitUntilDone:(BOOL)waitForMainThread;
@end

Then I have a protocol I defined:

@protocol MyDelegateProtocol <NSObject>
- (void)myDelegateProtocolMethod;
@end

Then I declare the delegate as a property of my class that implements said protocol.

@property (nonatomic, assign) id <MyDelegateProtocol> delegate;

But when I try to call the NSObject method I added in my category like so

NSInvocation *invocation = [self.delegate invocationForSelector:@selector(someSelector:withArg:)];

I get this warning

'-performInvocationOnMainThread:waitUntilDone:' not found in protocol(s)

If I cast my delegate as (NSObject *) then I don’t get the warning. What am I doing wrong? It didn’t seem like I could (or should?) add methods to an existing protocol without creating a “sub protocol” and using it from then on. (Which kind of defeats the point of adding methods to NSObject in mind.)

NSInvocation *invocation = [(NSObject *)self.delegate invocationForSelector:@selector(someSelector:withArg:)];
  • 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-22T01:44:51+00:00Added an answer on May 22, 2026 at 1:44 am

    Your category extends the NSObject class, not the NSObject protocol. While the class now has the method, it’s not defined as part of the protocol, hence the warning.

    That’s why typecasting to the NSObject * pointer type works; you’re casting to the NSObject class type, rather than something like id<NSObject> which means an arbitrary Objective-C object that conforms to the NSObject protocol.

    You’ll have to make an intermediate protocol (or “sub protocol”) that extends the NSObject protocol:

    @protocol ExtendedNSObject <NSObject>
    - (void)performInvocationOnMainThread:(NSInvocation *)invocation waitUntilDone:(BOOL)waitForMainThread;
    @end
    

    Then have your delegate protocol extend that one instead:

    @protocol MyDelegateProtocol <ExtendedNSObject>
    - (void)myDelegateProtocolMethod;
    @end
    

    If I’m not wrong, you can keep the existing NSObject (MyCategory) implementation, and they’ll play nice together.

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

Sidebar

Related Questions

I found some other questions about this, but they didn't work for me :(
I've found some questions here about this topic, but none of the solutions solve
I've found some questions that seem related to this one, but none describes exaclty
I found some good answers for this question, but I can't really get them
I saw some other similar questions on this topic here but they were not
I found some questions that looked similar, but not exactly the same so I'll
I found some mapkit code on the internet that looks like this: - (void)recenterMap
I found some information about this on Scott Hanselmans Blog Does anybody exactly know
I've read a number of SO questions on this topic, but grokking the applied
I was going through some questions related to C programming language. And i found

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.