siwft中单例的使用方法
创建单例
**
class TheOneAndOnlyKraken {
static let sharedInstance = TheOneAndOnlyKraken()
private init() {
print("helloWorld")
}
}
class Manager {
static let shared: Manager = {
let instance = Manager()
return instance
}()
}
**
用法
**
let manager = Manager.shared
let onceAndKrekon = TheOneAndOnlyKraken.sharedInstance
**
网友评论