For a custom class, the following works fine. But I'm getting errors that I think are specific to NSUserDefaults
class NSUserDefaultsManager:NSObject {
struct Static {
static var udefaults = NSUserDefaults.standardUserDefaults()
}
class var udefaults: [NSUserDefaults] {
get { return Static. udefaults }
set { Static. udefaults = newValue }
}
}
On the get
line, there is this error:
'NSUserDefaults' is not identical to 'AnyObject'
On the set
line, I get this:
'NSArray' is not subtype of 'NSUserDefaults'
The goal is to access udefaults like this NSUserDefaults.udefaults
. Do I need to create a property singleton for NSUserDefaults and access it like this NSUserDefaults.instance().udefaults?