【发布时间】:2022-02-24 11:03:12
【问题描述】:
这两种方法是否相同或是否存在需要注意的主要差异/陷阱:
class MyClassSingleton {
static let sharedInstance = MyClassSingleton()
private init(){}
func helloClass() { print("hello from class Singleton") }
}
struct MyStructSingleton {
static let sharedInstance = MyStructSingleton()
private init() {}
func helloStruct() { print("hello from struct Singleton") }
}
【问题讨论】:
标签: swift