I am currently learning objective-c from a book. In one example, before the class interface of a particular header file, it reads @class followed by two protocol declarations.
@class Thing;
@protocol Foo
-(void)foo:(Thing *);
@end;
@protocol Bar
-(void)bar:(Thing *);
@end;
@interface Thing : NSObject <Foo, Bar>
...
I understand that @class is used to prevent circular references, however I do not understand what is going on below that. Why are the protocols declared there, rather than in the @interface block?
Are they declared normally or forward declared?
In the former case then it’s just a declaration of a custom protocol, which is probably used by a class that is defined below (eg.
@interface MyClass : Object<MyProtocol>. Otherwise it’s a forward declaration needed for the same specific reason of a class forward declaration.