创建UI当我通过Interface Builder中创建用户界面,然后连接到IBOutlets我一直属性设置为弱...在代码性能
@property (nonatomic, weak) IBOutlet UILabel *someLabel;
然后在为UIViewController
代码可以参考我或_someLabel
,它工作正常。
不过,如果我成立了代码UI ...
@property (nonatomic, weak) UILabel *someLabel;
和...
self.someLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,0,10,10)];
然后我得到警告...
Assigning retained object to weak property; object will be released after assignment.
我通常的解决方法是将该属性更改为strong
,但我不确定这是否正确?
这样好吗?如果没有,是否有另一种方法来解决这个问题?
检查这个http://stackoverflow.com/questions/9752525/after-auto-arc-conversion-assigning-retained-object-to-unsafe-property-object – 2013-05-09 10:03:40