創建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