I'm trying to recompile SwiftyUserDefaults ( https://github.com/radex/SwiftyUserDefaults ) to add Carthage support, but when I try to compile, I see the following error
Ambiguous proxy type name in NSUserDefaults
for the following code
public func ?= (proxy: NSUserDefaults.Proxy, @autoclosure expr: () -> Any) {
if !proxy.defaults.hasKey(proxy.key) {
proxy.defaults[proxy.key] = expr()
}
}
and
"Proxies" are ambiguous for type searches in this context
for
public subscript(key: String) -> Proxy {
return Proxy(self, key)
}
As I understand it, the problem is with the Proxy class, which is built into the extension.
public extension NSUserDefaults {
class Proxy {
private let defaults: NSUserDefaults
private let key: String
private init(_ defaults: NSUserDefaults, _ key: String) {
self.defaults = defaults
self.key = key
}
public var object: NSObject? {
return defaults.objectForKey(key) as? NSObject
}
}
}
I was looking for documentation, but there is no reference to the fact that the class can be used in the extension.
Is it correct?
source
share