Question

I added a category to UIView to hold some transition helper methods. The methods are all working; however, I get compiler warnings:

warning: 'UIButton' may not respond to '-fadeOutWithDuration:'

My "UIView+Trans.h" file looks like this:

@interface UIImage (trans)
- (void) fadeOutWithDuration:(CGFloat)duration;
@end

My "UIView+Trans.m" file looks like this:

#import <QuartzCore/QuartzCore.h>
#import "UIView+Trans.h"

@implementation UIView (trans)
- (void) fadeOutWithDuration:(CGFloat) duration {
    //...
}
@end

And I'm calling the method like this: (and have #import "UIView+Trans.h" at the top of each file that uses the category method.) I've also tried casting the UIButton* to a UIView*.

[self.myButton fadeOutWithDuration:kFadeOutDuration];

I've used the "NSString+Reverse" example from this Categories Example article successfully in the same project and without the pesky warnings.

Was it helpful?

Solution

In your header file, you've declared the category on UIImage not UIView.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top