【发布时间】:2015-10-09 02:24:28
【问题描述】:
最初,我有一些非常简单的东西,如下所示。 UIAlertAction 的自定义类别,这样我就可以通过 [UIAlertAction okay] 创建一个好的操作;
@interface UIAlertAction (Custom)
+ (UIAlertAction *)okay;
@end
@implementation UIAlertAction (Custom)
+ (UIAlertAction *)okay
{
return [UIAlertAction actionWithTitle:@"Ok"
style:UIAlertActionStyleCancel
handler:nil];
}
@end
后来,我决定我也想要一个完整的hander,所以界面变成了这样:
@interface UIAlertAction (Custom)
+ (UIAlertAction *)okay;
+ (UIAlertAction *)okayWithHandler:(void (^ __nullable)(UIAlertAction *action))handler;
@end
然后我开始在第一行收到警告消息:
指针缺少可空性类型说明符
我认为理解可以为空的概念(老实说,这个名字很有描述性)。但我不明白的是,为什么在第二个函数上添加 __nullable 会使第一个函数必须具有可为空的说明符?
【问题讨论】:
标签: ios objective-c