add property in extension
generally extension can’t add peoperty
class extensionClass {
}
extension extensionClass {
private static var propertyKey: UInt8 = 0
var property: People? {
set {
objc_setAssociatedObject(self, &Self.propertyKey, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
}
get {
objc_getAssociatedObject(self,&Self.propertyKey) as? People
}
}
}
文章评论