Reputation: 29518
In Objective-C, why is it if you have a category for a class, and conform to a protocol in the category, why does the main class not know you conform to that category?
For example, some pseudo code
main class file
@implementation SessionManager
[SessionManager alloc] initWithDelegate:self]; // warning from Xcode saying that SessionManager is not the appropriate type
category file
@interface SessionManager (SomeCategory) <SessionManagerProtocol>
But if I just move the declaration of the conformance to the protocol in the main class file
@interface SessionManager : NSObject <SessionManagerProtocol>
The compiler does not generate a warning in that case. Is it just best to declare your conformance in the main class file?
Upvotes: 1
Views: 276
Reputation: 12154
You need to import category .h
file in main class .m
file so that complier can know these methods were declared in class category and it won't show warning.
Upvotes: 1