本文介绍了ARC禁止合成具有未指定所有权或存储的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了 @property UIColor

@property (nonatomic) UIColor *color;

然后我尝试合成它:

@synthesize color = _color;

但我收到一个错误:

所有我想做的是为一个 UIColor 对象创建一个属性, / p>

All I'm trying to do is to create a property for a UIColor object which changes color.

推荐答案

将您的资源声明更改为:

Change your property declaration to:

@property(nonatomic,strong)UIColor * color;

,以便ARC知道应该保留。这将编译没有 strong 之前的ARC,但它是危险的,因为默认是 assign ,颜色将已经

so that ARC knows it should be retained. This would have compiled without strong before ARC but it would be dangerous since the default was assign and the color would have been released unless it was retained elsewhere.

我强烈推荐关于ARC的WWDC2011视频。

I would highly recommend the WWDC2011 video about ARC.

这篇关于ARC禁止合成具有未指定所有权或存储的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 04:38