标签:har 调用 share string too 单利 name nil info
import UIKit
class SharedInfo: NSObject {
var nameStr:String? = "123" //设置初始值
struct ToolP {
static var myTool:SharedInfo?=nil
}
class func shareMyTool()->SharedInfo {
if(ToolP.myTool == nil){
ToolP.myTool=SharedInfo()
}
return ToolP.myTool!
}
}
调用方法
var myTool = SharedInfo.shareMyTool()
myTool.nameStr = "12312342423" // 此时nameStr的值是 :12312342423
var myTool2 = SharedInfo.shareMyTool()
String name = myTool2.nameStr
print(name!)
标签:har 调用 share string too 单利 name nil info
原文地址:http://www.cnblogs.com/lcl15/p/6879346.html