gpt4 book ai didi

ios - @property @synthesize 等价于swift

转载 作者:行者123 更新时间:2023-11-28 11:17:30 25 4
gpt4 key购买 nike

我有类似的东西

@property(nonatomic,retain) UIImageView *whiteBfFillUp;
@end

@synthesize locationManager;

我是快速编码的新手。谁能告诉我 swift 中的等效代码。

最佳答案

没有等价物。
在 Swift 中,当您在类或结构声明中编写 varlet 时,您已经声明了一个属性。

Define properties to store values

这是 Swift 文档中写的内容。如果您担心访问控制,您可以使用 privatepublic 修饰符。

public var somePublicVariable = 0

如果您想像在 Objective-C 中那样覆盖属性,您会发现有用的属性观察器,例如 didSet{} willSet{}
如果您需要一个只读属性,您可以将 setter 设为私有(private)。

public private(set) var hours = 0

关于ios - @property @synthesize 等价于swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30749211/

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