Reputation: 1510
I have two implementation in a single file. Like the one below. How do I access the second's method in the first? If I try to do that the compiler throws an unknown selector error.
I know that in C you have to have methods which have to have hierarchy in definitions to be able to build. Is this the same in ObjectiveC also? Are there any alternatives to this other than defining the second implementation above the first?
@implementation BaseClass
-(void)someMethod {
XCUIElementQuery *elementQuery = [[XCUIApplication alloc] init].tables
[elementQuery anotherMethod]; //How do I use the category method here?
}
@end
@implementation XCUIElementQuery (BaseClassCategory)
-(void)anotherMethod {
//do something
}
@end
Upvotes: 0
Views: 38
Reputation: 712
At the top of the file, just declare an interface for XCUIElementQuery like so:
@interface XCUIElementQuery (XCUIElementQuery_private)
-(void)anotherMethod;
@end
Upvotes: 1
Reputation: 318954
Just swap the two sets of implementations.
@implementation XCUIElementQuery (BaseClassCategory)
-(void)anotherMethod {
//do something
}
@end
@implementation BaseClass
-(void)someMethod {
XCUIElementQuery *elementQuery = [[XCUIApplication alloc] init].tables
[elementQuery anotherMethod]; //How do I use the category method here?
}
@end
Upvotes: 0