Skip to content

Instantly share code, notes, and snippets.

@jackyshan
Created May 18, 2017 01:32
Show Gist options
  • Select an option

  • Save jackyshan/1376733a88c08e02cda25a8a0afad5d0 to your computer and use it in GitHub Desktop.

Select an option

Save jackyshan/1376733a88c08e02cda25a8a0afad5d0 to your computer and use it in GitHub Desktop.
swift实现setter和getter的方法
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