【发布时间】:2016-06-24 07:33:17
【问题描述】:
我正在尝试创建一个访问单例的方法。我收到此错误(请参阅下面的代码)。我不明白为什么会收到此错误以及此错误的含义。谁能解释一下?
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
static private var thedelegate: AppDelegate?
class var delegate : AppDelegate {
return thedelegate!
}
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
thedelegate = self // syntax error: Static member 'thedelegate' cannot be used on instance of type 'AppDelegate'
【问题讨论】:
-
AppDelegate.thedelegate = self -
这就是这个问题的解决方案,但是Sasha已经解释过了
标签: swift