swift 单例

来源:互联网 发布:淘宝阿迪达斯高仿店铺 编辑:程序博客网 时间:2024/06/10 00:35
class Car: NSObject {    static let shareInstance = Car()    static var count:Int!    var member:Int!    override private init()      //构造函数没有返回值    {    super.init()    count = 0    ......    }    class func staticFunction()    {        NSLog("staticFunction")        count** += 1           //类方法中可以直接访问 类变量           car.member = 1      //类方法中不能直接访问单例成员变量    }}
0 0