gpt4 book ai didi

ios - 错误 : expected a property attribute before 'atomic'

转载 作者:可可西里 更新时间:2023-11-01 17:02:35 25 4
gpt4 key购买 nike

我在这一行得到以下异常:

@property (atomic ,retain) NSString *title;

error: expected a property attribute before 'atomic'

这是什么意思?

最佳答案

在声明的属性中没有关键字 atomic 可以使用。声明的属性默认表现为“原子”,因此您不必明确设置它。您只需通过添加非原子来更改默认行为。由于这是一个编译时指令,因此不需要在运行时更改此值,因此不需要“原子”。

引用 Apple 的 The Objective-C Programming Language / Declared Properties

Atomicity

You can use this attribute to specify that accessor methods are not atomic. (There is no keyword to denote atomic.)

nonatomic Specifies that accessors are nonatomic. By default, accessors are atomic. Properties are atomic by default so that synthesized accessors provide robust access to properties in a multithreaded environment—that is, the value returned from the getter or set via the setter is always fully retrieved or set regardless of what other threads are executing concurrently. For more details, see “Performance and Threading.”

关于ios - 错误 : expected a property attribute before 'atomic' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5900610/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com