Search code examples
iosuialertviewobjective-c-category

UIAlertView category : getting error


How's it going, I'd like to use the UIAlertView category, but I'm getting an error use of undeclared identifier UIAlertView & cannot find interface declaration for UIAlertView. What I'm doing wrong?

Here is.h

#import <Foundation/Foundation.h>

@interface UIAlertView(error)

+(void)error:(NSString*)msg;

@end

Here is .m

#import "UIAlertView+error.h"

@implementation UIAlertView(error)
+(void)error:(NSString*)msg
{
    [[[UIAlertView alloc] initWithTitle:@"Error"
                            message:msg
                           delegate:nil
                  cancelButtonTitle:@"Close"
                  otherButtonTitles: nil] show];
}
@end

Any ideas?


Solution

  • This is a category on UIAlertView and UIAlertView is in UIKit, not Foundation. So

    #import <UIKit/UIKit.h>