亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

在objective-c中atomic和nonatomic有什么區(qū)別?retain有什么用?
高洛峰
高洛峰 2017-04-21 10:57:07
0
4
539

比如下面的代碼

@property(nonatomic, retain) UITextField *userName;
@property(atomic, retain) UITextField *userName;

他們有啥區(qū)別,retain在這里起啥作用

高洛峰
高洛峰

擁有18年軟件開發(fā)和IT教學(xué)經(jīng)驗(yàn)。曾任多家上市公司技術(shù)總監(jiān)、架構(gòu)師、項(xiàng)目經(jīng)理、高級(jí)軟件工程師等職務(wù)。 網(wǎng)絡(luò)人氣名人講師,...

reply all(4)
左手右手慢動(dòng)作

retain is to add 1 to the reference count of the attribute
The retain here means that this setter will add 1 to the reference count of the parameter. For example:

self.userName = uName;

At this time, the reference count of uName will be increased by 1.
However, SDK 5.0 and later supports ARC, which means automatic application counting. Therefore, there is no need to retain and copy when defining attributes. Instead, use strong to let ARC manage it.
An article providing apple core for reference: http://pingguohe.net/2011/08/05/llvm3...

黃舟

Atomic is thread safe and has lower performance than nonatomic. noatomic does not guarantee thread safety.

左手右手慢動(dòng)作

atomic does not mean thread safety, it just means that set and get operations on the same object are executed sequentially.

阿神

The difference between iOS atomic and nonatomic

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template