Created
May 18, 2017 01:32
-
-
Save jackyshan/1376733a88c08e02cda25a8a0afad5d0 to your computer and use it in GitHub Desktop.
swift实现setter和getter的方法
This file contains hidden or 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
| private var key: Void? | |
| extension MAPolyline { | |
| var isWalk: Bool? { | |
| get { | |
| return objc_getAssociatedObject(self, &key) as? Bool | |
| } | |
| set { | |
| objc_setAssociatedObject(self, | |
| &key, newValue, | |
| .OBJC_ASSOCIATION_RETAIN_NONATOMIC) | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment