The following code produces error No visible @interface for 'Bar' declares the selector 'barMethod' on the second line of implementation of -[Foo fooMethod]:
// FooBar.m
#import "FooBar.h"
//////////////////////////////////
@implementation Foo
- (void)fooMethod {
Bar *bar = [Bar new];
[bar barMethod]; // Error: No visible @interface for 'Bar' declares the selector 'barMethod'
}
@end
//////////////////////////////////
@interface Bar ()
- (void)barMethod;
@end
@implementation Bar
- (void)barMethod {
// do something
}
@end
Is there any way to forward declare -[Bar barMethod] inside FooBar.m other than moving Bar class extension above Foo implementation (which is not very convenient at times)?