Synthesised properties for primitive data types using ARC -- weak or assign?
I was wondering what is the correct way to write synthesised properties for primitive data types (like bool) when ARC is enabled.
I used to use this before ARC:
@property(assign) bool isOn;
But it is my understanding开发者_运维技巧 (maybe wrong) that you shouldn't use assign when ARC is enabled. I tried replacing this with weak but I get the error -
Property of "weak" attribute must be of type object.
Should I continue to use assign?
Assign is fine. ARC stands for "Automatic Reference Counting", and primitive data types do not have reference counts.
Weak failed because there is no object, nor any references for ARC to manage.
Seems you need to read up on a certain subject here. Check: http://clang.llvm.org/docs/AutomaticReferenceCounting.html
Check chapter 4 ;) Here you will read that assign is fine with ARC.
When ARC Enabled you can write synthesised properties for primitive data like(ex:BOOL).. @property(unsafe_unretained) bool isOn;
加载中,请稍侯......
精彩评论