我有一个 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 宏吗?