简体   繁体   English

我是否必须在objective-c ios编程中使用非原子属性?

[英]Do I have to use nonatomic property in objective-c ios programing?

I'm developing an iPhone app. 我正在开发一款iPhone应用程序。

All the iPhone development books I have read use nonatomic property. 我读过的所有iPhone开发书籍都使用非原子属性。
And IBOutlets which xcode generates also use nonatomic keyword. xcode生成的IBOutlets也使用非原子关键字。

But I don't like to write nonatomic on every property because it decrease readability too much. 但我不喜欢在每个属性上写nonatomic ,因为它会降低可读性。

Are there any problem if I do not use nonatomic keyword for all properties? 如果我不对所有属性使用nonatomic关键字,是否有任何问题?

If nonatomic keyword makes my app only a little bit faster, I want to delete all nonatomic keywords. 如果非原子关键字使我的应用程序更快一点,我想删除所有nonatomic关键字。
Is it good idea? 这是好主意吗?

If you delete nonatomic from property then by default all your properties will be 'atomic'. 如果从属性中删除nonatomic ,则默认情况下所有属性都将为“原子”。 If there are a lot of 'atomic' properties without purpose then it will slow up your app, because at compile time atomic properties generate a complex code and every time you use that property that code will be executed. 如果存在大量没有目的的“原子”属性,那么它将减慢您的应用程序,因为在编译时原子属性生成复杂的代码,并且每次使用该属性时代码将被执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM