解決在 Xcode 5.1环境下property所造成的 synthesis warning问题?
来源:互联网 发布:mac打印jpeg 编辑:程序博客网 时间:2024/05/02 16:56
將 Xcode 升级到最新的 5.1,在使用AFNetworking时遇到了 property synthesis相关的 error,错误信息如下:
Auto property synthesis will not synthesize property 'request' because it is 'readwrite' but it will be synthesized 'readonly' via another property
Auto property synthesis will not synthesize property 'response' because it is 'readwrite' but it will be synthesized 'readonly' via another property
在AFHTTPRequestOperation中定义了:
@property (readwrite, nonatomic, strong) NSURLRequest *request;
@property (readwrite, nonatomic, strong) NSHTTPURLResponse *response;
就是这样的代码,会让 request property出现 warning。原因是因为 compiler 读取 sub-class 時,会发现 request 明明应该是個 readonly property(super-class讲的),但你却要将它设为 readwriteproperty,所以 compiler不知道该怎么 auto synthesis。
但你知道 super-class 的实现,也会将这个 property 改成 readwrite,因此你在 sub-class的实现里这样子写是不会有问题的。可是 compiler 不知道啊,這要怎么办呢?
你要告诉 compiler,要它不用担心。那要怎么告诉 compiler呢?你需要的是 @dynamic,它是一种给 compiler的「承诺」,承诺它「虽然你现在不知道该怎么办,但是在 runtime 的时候你就会知道了」。所以只要把代码改成以下这样就可以了:
@implementation AFHTTPRequestOperation
@dynamic response;
@dynamic request;
@end
- 解決在 Xcode 5.1环境下property所造成的 synthesis warning问题?
- 解決在 Xcode 5.1环境下property所造成的 synthesis warning问题?
- 升级到最新xcode,在使用AFNetworking时遇到了 property synthesis 相关的 error
- Xcode升级了6.3 出现的警告:Auto property synthesis will not synthesize property
- Automatic Property Synthesis With Xcode 4.4
- Xcode: Auto property synthesis will not synthesize property 解决
- swftools在linux环境下的安装与所遇问题的解决方法(总结精华)
- 关于Xcode下编译突然造成硬盘消耗十几G的问题
- [IOS]在xcode开发编译环境中@property关键字的理解
- 深入浅出@property 与 @synthesis
- IOS开发Git在Xcode开发环境下的使用
- Xcode环境配置文件在Mac下的路径
- 在linux上搭建hadoop环境所遇到的问题
- 使用AFNetworking时遇到了 property synthesis 相关的 error
- const_cast所造成的同地址不同值问题
- 关于hibernate持久化所造成的问题以及解决方案
- java虚拟机中的invokevirtual所造成的问题
- 在无GUI的Linux环境下将vim编辑器打造成一款Python开发IDE
- linux常用命令
- 【Unity3D插件】NGUI屏幕自适应
- 用pygame写个简单的贪吃蛇游戏
- Java第6周实验
- 《算法导论》笔记 第7章 7.4快速排序分析
- 解決在 Xcode 5.1环境下property所造成的 synthesis warning问题?
- debian7.4安装手记
- Berkeley DB数据库和日志文件归档
- Java本地调用JNI使用规范详解
- 终于有点眉目
- 青春--说走就走的旅行
- 如何使用DDMS查看某个进程的logcat
- js中的arguments对象
- jquery | 淡化版banner 带标题+描述 和 小按钮