iOS动态派发 - 修改fileprivate属性
2020-09-09 本文已影响0人
等这姑娘老在我心里
public class Demo : NSObject{
@objc fileprivate var name = "123"
func namePrint(){
print(name)
}
}
var demo = Demo()
demo.namePrint()//123
objc_setAssociatedObject(demo, "name", "321", objc_AssociationPolicy(rawValue: 3)!)
demo.namePrint()//123
demo.setValue("321", forKey: "name")
demo.namePrint()//321