lenhhoxung
lenhhoxung

Reputation: 2766

Access method in another interface of same class

I'm stuck on this problem, please help me. I have a ViewController with class name: FLViewController. In the .m file, I declare some other interfaces:

@interface FLViewController (InternalMethods)
- (void)updateButtonStates;
@end

@interface FLViewController (AVCaptureManagerDelegate) <AVCaptureManagerDelegate>
-(void)adMobProcess
@end

In the implementation of FLViewController, I call method adMobProcess of Interface FLViewController (AVCaptureManagerDelegate) but the compiler said that "No visible @interface for FLViewController declares selector adMobProcess"

I can move the method above into the implementation of FLViewCOntroller (currently it is placed in the category AVCaptureManagerDelegate) however, I want to know how to call the method in another category.

Upvotes: 0

Views: 244

Answers (2)

lenhhoxung
lenhhoxung

Reputation: 2766

Finally I found the cause. I didn't declare method signature in the Category, just only the method implementation in the Category implementation block.I declared the method and it works.

Upvotes: 0

TotoroTotoro
TotoroTotoro

Reputation: 17622

By declaring your categories inside the .m file (which limits their scope to that one file), you've effectively declared some private methods for FLViewController. If this is what you want, you don't need categories.

Categories in Objective-C are meant to be reused. So you want to declare your categories in a header file (or files), and include those headers in any .m file where you use them.

Upvotes: 1

Related Questions