Well, I have these two protocols:
@protocol ivAuthorizationProtocol <NSObject>
-(void)loginReply:(ivSession*)session;
@end
@protocol ivServerListsProtocol <NSObject>
-(void)serverListLoaded:(NSArray*)serverList;
@end
and have class
@interface ivClientAppDelegate : NSObject <UIApplicationDelegate>
...
@end
@implementation
...
-(void)authorizeWithLogin:(NSString*)login andPassword:(NSString*)password
{
self.login = login;
self.password = password;
// !!! delegate in the next call should conform to ivAuthorizationProtocol,
// so i get warning "class does not implement protocol ivAuthoriaztionProtocol" here
[_apiWrapper authorizeWith:login andPassword:password forDelegate:self];
}
...
@end
I want to put the implementation of the protocol’s methods in separate files (categories) so not to mess up the main implementation file. For example, the header of the category for implementation of ivAuthorizationProtocol looks like this:
#import "ivClientAppDelegate.h"
@interface ivClientAppDelegate (ivAuthorizationResponder) <ivAuthorizationProtocol>
-(void)loginReply:(ivSession*)session;
@end
So, the question is – how can I get rid of the warning I get in the main implementation file? How can I tell the compiler that methods conforming to the protocol are located in categories?
Thanks in advance!
You could use a cast to silence the warning:
Other than that, you can’t do what you want without getting different warnings (unimplemented methods). Normally you would specify the protocol in the interface:
But then you would need to implement the methods in you main
@implementationblock.Please note that by convention class and protocol names should start with an uppercase character.