Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/102.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 方法分派时缺少sentinel,尽管参数列表中存在nil_Ios_Objective C_Cocoa Touch_Compiler Warnings_Sentinel - Fatal编程技术网

Ios 方法分派时缺少sentinel,尽管参数列表中存在nil

Ios 方法分派时缺少sentinel,尽管参数列表中存在nil,ios,objective-c,cocoa-touch,compiler-warnings,sentinel,Ios,Objective C,Cocoa Touch,Compiler Warnings,Sentinel,我想创建一个UIActionSheet,但我总是收到关于“缺少哨兵”的警告: /Users/…mm:136:173:警告:方法分派中缺少哨兵[-Wsentinel] UIActionSheet*adsl\u action\u sheet=[[[UIActionSheet alloc]initWithTitle:nil 代表:(id)self CancelButtontile:[dsd\U字符串\U定位器ms\U获取\U本地化\U系统\U字符串:@“取消”] 破坏性按钮:无 其他按钮提示:[dsd

我想创建一个
UIActionSheet
,但我总是收到关于“缺少哨兵”的警告:

/Users/…mm:136:173:警告:方法分派中缺少哨兵[-Wsentinel]

UIActionSheet*adsl\u action\u sheet=[[[UIActionSheet alloc]initWithTitle:nil
代表:(id)self
CancelButtontile:[dsd\U字符串\U定位器ms\U获取\U本地化\U系统\U字符串:@“取消”]
破坏性按钮:无
其他按钮提示:[dsd_字符串_定位器ms_获取_本地化_系统_字符串:@“注销”],[dsd_字符串_定位器ms_获取_本地化_系统_字符串:@“断开”],无]自动释放];
我真的看不出有什么不对。。。也许我只是瞎了

包含此代码的文件是Objective-C++文件


我还注意到,它在每个需要这样一个哨兵的地方都显示了这些“哨兵警告”。

从编译器输出中,我认为您没有在变量方法调用的末尾正确地放置
nil

您需要使用以下命令将最后的“哨兵”
nil
转换为正确的类型:

... , (NSString *)nil] autorelease];
//    ^^^^^^^^^^^^
但是,我不确定编译器为什么需要这种强制转换


我相信在使用
-Wstrict null sentinel
(等待OP确认)进行编译时,这是必要的。

显示完整的编译器警告消息。@特洛伊木马程序我从日志中添加了警告,希望这是您想要的。看起来编译器没有看到最后的
nil
。如果将其更改为
(NSString*)nil
,会发生什么情况?(NSString*)nil产生了奇迹,警告消失了。非常感谢你!你能解释一下为什么需要施放吗?@tiguero不,我不能,但我还没有仔细看过。被接受的人,很想知道你为什么要施放。@ManuelWa你是用旗帜
-Wstrict null sentinel
编译的吗?@trojanfoe将在周五检查,明天上学,周五我又在上班
... , (NSString *)nil] autorelease];
//    ^^^^^^^^^^^^