Last active
November 1, 2019 02:50
-
-
Save Heilum/c84a9cea868cfa774cddf4a3423cf64a to your computer and use it in GitHub Desktop.
Setting associated userObject to UIView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UIView+SF.swift | |
// WechatTail | |
// | |
// Created by CHENWANFEI on 2019/9/22. | |
// Copyright © 2019 SwordFish. All rights reserved. | |
// | |
import UIKit | |
var g_UIView_AssociatedObjectHandle: UInt8 = 0 | |
extension UIView{ | |
var userObject:Any? { | |
get { | |
return objc_getAssociatedObject(self, &g_UIView_AssociatedObjectHandle) | |
} | |
set { | |
objc_setAssociatedObject(self, &g_UIView_AssociatedObjectHandle, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment