swifter-tips / Public-Issues

Public issues for Swifter-tips book

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

对于单例的 tip 有点疑惑

zyg-github opened this issue · comments

commented

class MyManager {
private static let sharedInstance = MyManager()
class var sharedManager : MyManager {
return sharedInstance
}
}
为什么还要定义 只读的计算属性 sharedManager 变量 有什么目的?
像下面这样定义不好吗?
class MyManager {
static let sharedInstance = MyManager()
private init() {}
}
我参考的是:http://www.devtf.cn/?p=937

没问题,你的做法比较好。

commented

好的 谢谢 喵神~
感觉看了你的tip 受益匪浅
有没有计划 出一些 高阶 ios 书之类的 不过不要卖太便宜了 卖个200大元也不贵 电子书形式就行了 实时更新~ 嘻嘻

厄- -...暂时没有这个精力和计划

Fixed and will update later.