Swift Extension 添加属性
class Company {
}
extension Company {
private static var NAME_kEY: Void?
var name: String {
get {
objc_getAssociatedObject(self, &Self.NAME_kEY) as! String
}
set {
objc_setAssociatedObject(self, &Self.NAME_kEY, newValue, .OBJC_ASSOCIATION_COPY_NONATOMIC)
}
}
}