1.最推荐的 swift 能保证线程安全
`class MySingleton {
static let shared = MySingleton()
private init() {// 私有化构造函数,防止外部创建实例
}func someMethod() {// 业务方法
}
}使用的时候直接调用// 使用
MySingleton.shared.someMethod()`
1.最推荐的 swift 能保证线程安全
`class MySingleton {
static let shared = MySingleton()
private init() {// 私有化构造函数,防止外部创建实例
}func someMethod() {// 业务方法
}
}使用的时候直接调用// 使用
MySingleton.shared.someMethod()`