It is my understanding that as of Xcode 6.3 / Swift 1.2, I can use static variables and methods inside of a class. However, the compiler doesn't like it when I try to initialize a static variable by calling a static function (I get the error 'Use of unresolved identifier getDefaultString' in the example below). Here is a snippet that demonstrates my problem:
import Foundation
public class Settings {
private static var _bundle = NSBundle.mainBundle()
static func getDefaultString(key: String) -> String {
return _bundle.objectForInfoDictionaryKey(key) as! String
}
private static var _server = getDefaultString("DefaultServer")
public class var server: String {
get { return _server }
set { _server = newValue }
}
}
Can someone help me understand why I can't do this?
private static var _server = Settings.getDefaultString("DefaultServer")?