gpt4 book ai didi

ios - 需要理解这个warning "Attributes on method implementation and its declaration must match"

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:29:58 24 4
gpt4 key购买 nike

我有一个 UIView 子类用作自定义警报 View ,它声明了这个 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

}

关于ios - 需要理解这个warning "Attributes on method implementation and its declaration must match",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18226495/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com