需要了解此警告"Attributes on method implementation and its declaration must match"



我有一个UIView子类用作自定义警报视图,它声明了这个init方法

@interface THAlertView : UIView   
- (id) initWithTitle:(NSString *)title message:(NSString *)message
    cancelButtonTitle:(NSString*)cancelButtonTitle
    otherButtonTitles:(NSString*)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION;
@end

在实现文件中,我简单地定义了方法

@implementation THAlertView
- (id) initWithTitle:(NSString *)title message:(NSString *)message
   cancelButtonTitle:(NSString*)cancelButtonTitle
   otherButtonTitles:(NSString*)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION {
// Create and return an instance of THAlertView
}

带有LLVM 4.2的XCode 4.6.3向我发出此警告

THAlertView.m:74:193: warning: attributes on method implementation and its declaration must match [-Wmismatched-method-attributes]
- (id)initWithTitle:(NSString *)title message:(NSString *)message cancelButtonTitle:(NSString*)cancelButtonTitle otherButtonTitles:(NSString*)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION {
                                                                                                                                                                                               ^
THAlertView.h:29:1: note: method 'initWithTitle:message:cancelButtonTitle:otherButtonTitles:' declared here
- (id)initWithTitle:(NSString *)title message:(NSString *)message cancelButtonTitle:(NSString*)cancelButtonTitle otherButtonTitles:(NSString*)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION;
^
1 warning generated.

我理解这个警告是关于什么的,但这次我不知道如何解决它。对我来说,一切似乎都很好,但也许我错过了什么。可能是因为NS_REQUIRES_NIL_TERMINATION宏?

从实现文件中删除NS_REQUIRES_NIL_TERMINATION

@implementation THAlertView
- (id) initWithTitle:(NSString *)title message:(NSString *)message
   cancelButtonTitle:(NSString*)cancelButtonTitle
   otherButtonTitles:(NSString*)otherButtonTitles, ... {
// Create and return an instance of THAlertView
}

最新更新