Skip to content

Instantly share code, notes, and snippets.

@ZHocean123
Created November 21, 2017 06:22
Show Gist options
  • Select an option

  • Save ZHocean123/e141fbd304122db9f3ccc4f6270b6846 to your computer and use it in GitHub Desktop.

Select an option

Save ZHocean123/e141fbd304122db9f3ccc4f6270b6846 to your computer and use it in GitHub Desktop.
class MyClass {
}
private var key: Void?
extention MyClass {
var title: String? {
get {
return objc_getAssociatedObject(self, &key) as? String
}
set {
objc_setAssociatedObject(self, &key, newValue, .OBJC_ASSOCIATED_RETAIN_NONATOMIC)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment