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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:09:45+00:00 2026-06-03T00:09:45+00:00

I have a protocol like this: #import <Foundation/Foundation.h> @protocol Prot1 <NSObject> @required – (void)methodInProtocol;

  • 0

I have a protocol like this:

#import <Foundation/Foundation.h>

@protocol Prot1 <NSObject>

@required
- (void)methodInProtocol;

@end

This is a protocol for a delegate I want to store in a class like this:

#import <Cocoa/Cocoa.h>

@class Prot1;

@interface Class1 : NSObject

@property (nonatomic, strong) Prot1 *delegate;

- (void)methodInClass;

@end

The implementation for this class is like this:

#import "Class1.h"
#import "Prot1.h"

@implementation Class1

@synthesize delegate;

- (void)methodInClass {
    [delegate methodInProt];
}

@end

When I build these pieces of code, I get the following error:

Receiver type 'Prot1' for instance message is a forward declaration

What is wrong here? I did understand that I have to do a forward declaration via @class for the protocol and I thought I only had to #import the protocol, in the class implementation… Isn’t that right?

  • 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-06-03T00:09:47+00:00Added an answer on June 3, 2026 at 12:09 am

    As it isnt a class, you have to define it as what it is – a protocol 😉

    Use forward declaration: @protocol Prot1;;

    And use the property like that:
    @property (nonatomic, strong) id<Prot1> delegate;

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

Sidebar

Related Questions

I have defined a protocol like this: @protocol RSSItemParserDelegate <NSObject> - (void)RSSItemParser:(RSSItemParser *)parser didEndParsingSuccesfully:(BOOL)success;
I have defined a delegate protocol in my custom class this way: #import <Foundation/Foundation.h>
I have a protocol in Objective-C, something like this: @protocol Handler +(NSString*) getValue; @end
Well, I have these two protocols: @protocol ivAuthorizationProtocol <NSObject> -(void)loginReply:(ivSession*)session; @end @protocol ivServerListsProtocol <NSObject>
I have the following method: -(void)SomeMethod:(id)classOrProtocol; It will be called like this: [self someMethod:@protocol(SomeProtocol)];
Say I create a class and a protocol like this: @protocol MyProtocol @required -
I have a protocol buffer setup like this: [ProtoContract] Foo { [ProtoMember(1)] Bar[] Bars;
I have a protocol that is defined like this: @protocol Container - (BOOL)putStuff: (Stuff
Is it ok to have message like this? message A { required int64 some_number
I have a simple class that looks a bit like this: @protocol Recorder @property(BOOL)

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.