my code:
public protocol ApiRequestBaseObjProtocol {
var param:[String:Any] { get set }
var path:String {get}
}
extension ApiRequestBaseObjProtocol {
var param: [String : Any] {
get {
var key = "\(self.path)"
return (objc_getAssociatedObject(self, &key) as? [String : Any]) ?? [:]
}
set(newValue) {
var key = "\(self.path)"
objc_setAssociatedObject(self, &key, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
}
}
}
enum MeApi : ApiRequestBaseObjProtocol {
public var path: String {
return "test/api/xxx"
}
}
at param get{} method : objc_getAssociatedObject(self, &key) aways be nil. I want to know why? thank you!!