Pointer is missing a nullability type specifier (__nonnull or __nullable)
我们都知道在swift中,可以使用!和?来表示一个对象是optional的还是non-optional,如view?和view!。而在Objective-C中则没有这一区分,view即可表示这个对象是optional,也可表示是non-optioanl。这样就会造成一个问题:在Swift与Objective-C混编时,Swift编译器并不知道一个Objective-C对象到底是optional还是non-optional,因此这种情况下编译器会隐式地将Objective-C的对象当成是non-optional。
为了解决这个问题,苹果在Xcode 6.3引入了一个Objective-C的新特性:nullability annotations。这一新特性的核心是两个新的类型注释:__nullable和__nonnull。从字面上我们可以猜到,__nullable表示对象可以是NULL或nil,而__nonnull表示对象不应该为空。当我们不遵循这一规则时,编译器就会给出警告。
typedef enum : NSUInteger {
LoadTypeNew, ///下拉刷新,加载最新数据的状态
LoadTypeMore, /// 上拉刷新,加载更多数据的状态
LoadTypeSearch /// 控制器搜索数据的状态
} LoadType; //这个block , 用来解决是不是已经把数据加载完成了(没有更多的数据了)
typedef void(^SuccessWithLastBlock)(_Nonnull id success, BOOL last); //这个block , 用来解决请求数据出错的情况(包含error 信息 和服务器返回的错误信息,error为空 ,即为服务器错误)
typedef void(^ErrorMsgBlock)( NSError * _Nullable error,id _Nullable msgBody); @interface QKYBasicDataController : NSObject @property (nonatomic,strong,nonnull)SuccessWithLastBlock successWithLastBlock; //默认的成功的回调
@property (nonatomic,strong,nonnull)SuccessBlock successBlock; //默认的成功的回调
@property (nonatomic,strong,nonnull)ErrorMsgBlock errorMsgBlock; //默认的失败的回调 // 传入交互的Block块,这个只是提供一般的例子,在具体的DataController中为了增加可读性,需要自定义
-(void)requestDatasWithSusscessBlock: (_Nullable SuccessBlock ) successBlock ErrorMsgBlock:(_Nullable ErrorMsgBlock )errorMsgBlock;
@end
上边的代码是一个基础ViewModel的代码,在使用block的时候只要加上这两个属性 进行说明就不会有警告了
Pointer is missing a nullability type specifier (__nonnull or __nullable)的更多相关文章
- warning:Pointer is missing a nullability type specifier (__nonnull or __nullable)
当我们定义某个属性的时候 如果当前使用的编译器版本比较高(6.3+)的话经常会遇到这样一个警告:warning:Pointer is missing a nullability type speci ...
- 警告:Pointer is missing a nullability type specifier (__nonnull or __nullable)
当我们定义某个属性的时候 如果当前使用的编译器版本比较高(6.3+)的话经常会遇到这样一个警告: 而且奇怪的是在某些文件中定义这个属性是没有任何警告的 但是在某些文件中定义同样的属性就会报错: 其实 ...
- error C4430:missing type specifier 解决错误
错误 3 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int ...
- MFC中使用ATL报错:error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
我在MFC中使用ATL函数A2W的时候报如下的错误: error C4430: missing type specifier - int assumed. Note: C++ does not sup ...
- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 解决方法
在VS2012中生成时出错:error C4430: missing type specifier - int assumed. Note: C++ does not support default- ...
- 做MFC的时候引用了头文件但VC还是报missing storage-class or type specifiers
我在客户端clg.h头文件中引用了头文件“ClientSocket.h”,然后在客户端clg.h中的类中声明了类CClientSocket的对象,可是编译报错:d:\vc++\客户端\客户端dlg.h ...
- GetDocument missing storage-class or type specifiers的解决方法
error C2143: syntax error : missing ';' before '*'error C2501: 'CTest1Doc' : missing storage-class o ...
- declaration specifier, declarator, type specifier
static struct abc * b; static struct abc : declaration specifier * b : declarator struct abc : type ...
- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
以前一直用的VC6.0,最近换成VS2010了.哎这几天光折腾VS2010了. 曾经我以为程序没啥头绪忒头疼,现在觉得乱七八糟的编译问题才叫一个头裂=口= 原因:VC6.0中,如果没有直接显示指定的返 ...
随机推荐
- 前端自动化工具gulp自动添加版本号
之前,我介绍了学习安装并配置前端自动化工具Gulp,觉得gulp确实比grunt的配置简单很多,于是我决定再深入学习一下gulp,就去网上查了资料,发现gulp还可以自动添加版本号,这个功能就为我平时 ...
- C++构造函数/析构函数 设置成private的原因
C++构造函数/析构函数 设置成private的原因 标签(空格分隔): c/c++ 将构造函数,析构函数声明为私有和保护的,那么对象如何创建? 已经不能从外部调用构造函数了,但是对象必须被构造,应该 ...
- 查看sbt版本
进入 sbt 命令行模式, 键入sbtVersion 得到[info]0.13.12
- 转:CentOS, 找不到dump命令:command not found
dump 功能说明:备份文件系统.语 法:dump [-cnu][-0123456789][-b <区块大小>][-B <区块数目>][-d <密度>][-f &l ...
- mongoose 和 mongoDB
第三方学习地址:http://blog.csdn.net/foruok/article/details/47746057 下载mongoDB https://www.mongodb.com/downl ...
- 初学java之12 泛型编程的个人理解总结
首先,强调一个观点: 对于我这样的初学者,一定要站在虚拟机和编译器的角度来分析java 语言的种种特性,泛型也不例外.(我认为这个一条正确的学习经验) 写这篇文章起源于最近在学java,有一天在路上和 ...
- java 多线程 继承Thread和实现Runnable的区别
1)继承Thread: public class ThreadTest extends Thread { private int count; private String name; public ...
- c#解析XML到DATASET及dataset转为xml文件函数
//将xml对象内容字符串转换为DataSet public static DataSet ConvertXMLToDataSet(string xmlData) { ...
- [Voice communications] 声道的转换
本系列文章主要是介绍 Web Audio API 的相关知识,以及 web语音通信 中会遇到的一些问题,阐述可能存在错误,还请多多斧正! 很多粤语剧都提供了两个声道,一个左声道为粤语,一个右声道有国语 ...
- windows命令——explorer
转至http://www.cnblogs.com/ymind/archive/2012/03/30/explorer-command-args.html 今天才知道,explorer原来可以这样用, ...