class ca{
var count = 1;
static var instance:ca =
ca();
class func GetInstance()->ca{
return instance;
}
}
var a = ca.GetInstance();
var b = ca.GetInstance();
a.count = 2;
println("\(a.count),\(b.count)");//2,2
时间: 2024-10-27 18:10:48
class ca{
var count = 1;
static var instance:ca =
ca();
class func GetInstance()->ca{
return instance;
}
}
var a = ca.GetInstance();
var b = ca.GetInstance();
a.count = 2;
println("\(a.count),\(b.count)");//2,2