I got SO questions also same as this and I tried with solution but still its not working for mine so asked this again.
This is my VCWithProtocol.h
@protocol mydemoDelegate
@optional
-(void)demoDelegateMethodWithSuccess:(BOOL)yesOrNo;
@end
@interface VCWithProtocol : UIViewController
{
id<mydemoDelegate>mydelegate;
}
@property (nonatomic,assign)id<mydemoDelegate>mydelegate;
VCWithProtocol.m
`@synthesize mydelegate`
This is my class where I am trying to use my Delegate
@class VCWithProtocol;
@interface VCTOUseDelegate : UIViewController <mydemoDelegate> //here is where it shows error with cannot find protocol declaration
VCTOUseDelegate.m
VCWithProtocol *obj = [[VCWithProtocol alloc] init];
obj.mydelegate = self;
I tried with Importing VCWithProtocol but not working as well
Instead of
@class VCWithProtocol;write#import VCWithProtocol.hAnd some good practice Use capital letter for first character of any class name and protocol.
e.g.
MyDemoDelegateand avoid retaining delegate use