[Swift] 纯文本查看 复制代码
private var delegateKey: TSBaseViewDelegate? = nil
private var dataArrayKey: Array<AnyObject>? = nil
extension UIScrollView {
   
    weak var baseScrollViewDelegate: TSBaseScrollViewDelegate? {
        set {
            objc_setAssociatedObject(self, &delegateKey, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_ASSIGN)
        }
        get {
            return (objc_getAssociatedObject(self, &delegateKey) as? TSBaseScrollViewDelegate)!
        }
    }
    var dataArray: Array<AnyObject?>? {
        set {
            objc_setAssociatedObject(self, &dataArrayKey, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN)
        }
        get {
            return (objc_getAssociatedObject(self, &dataArrayKey) as? Array)!
        }
    }
}



Swift中怎么为UIScrollView增加一个数组属性?

Swift中怎么为UIScrollView增加一个数组属性? - 敏捷大拇指 - Swift中怎么为UIScrollView增加一个数组属性?