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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:32:34+00:00 2026-05-27T08:32:34+00:00

I have implementation of Objective-C Protocol which forward all protocol’s methods to another target.

  • 0

I have implementation of Objective-C Protocol which forward all protocol’s methods to another target. Everething is fine except that compiler warns that this Class doesn implement protocol’s method. I am trying suppress this warning using #pragma diagnostic:

//Header file
@protocol A
-(void)test;
@end

@interface AImpl : NSObject<A> {
    id<A> myItems;
}
@end

//Implementation file:
#pragma GCC diagnostic push
#pragma clang diagnostic push

#pragma GCC diagnostic ignored "-Wno-protocol"
#pragma clang diagnostic ignored "-Wno-protocol"

@implementation AImpl
- (void)forwardInvocation:(NSInvocation *)invocation {
SEL selector = [invocation selector];

    if ([myItems respondsToSelector:selector]) {
    [invocation invokeWithTarget:myItems];
} else {
    [super forwardInvocation:invocation];
}
}
@end

#pragma clang diagnostic pop
#pragma GCC diagnostic pop

But compiler warns that “Unknown warning group ‘-Wno-protocol'”

  • 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-27T08:32:35+00:00Added an answer on May 27, 2026 at 8:32 am

    You’ve 3 immediate approaches:

    1) you can do this instead:

    #pragma GCC diagnostic ignored "-Wprotocol"
    #pragma clang diagnostic ignored "-Wprotocol"
    

    you specify the group to disable using the pragma, rather than the compiler flag to set/alter.

    2) or you can correct the issue like so (assuming you are not declaring a root class):

    @interface AImpl : NSObject<A>
    {
      id<NSObject,A> myItems;
    }
    @end
    

    3) or you can specify the setting on a per-file basis in Xcode’s Project > Target > Build Phases > Compile Sources > Compiler Flags = “-Wno-protocol”

    I’d go with #2.

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

Sidebar

Related Questions

I want to recognize uppercase letters using objective-c. I have an implementation now that
Can a Objective c interface have more than one implementation? Example I could have
Would you call this implementation of a multiton in objective-c 'elegant'? I have programmatically
I know that it's OK for a pure virtual function to have an implementation.
I have written an Objective-C framework which builds some HTML code with NSMutableString which
I wonder about Objective-C style. I have FooClass.[hm] that depends on BarClass.[hm] for its
I'm new to Objective C. I am trying to define Constants which have behavior
I am writing a simple console application in Objective-C but I have heard that
I have an Objective-c class MyClass. In MyClass.m I have a class extension that
I have an Objective-C NSMutableDictionary declared inside a class's @interface section, with getter/setter methods,

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.