Skip to content

Instantly share code, notes, and snippets.

@fcaldarelli
Created September 7, 2018 22:07
Show Gist options
  • Save fcaldarelli/d4f80f831bee076556efac7d5f0ec060 to your computer and use it in GitHub Desktop.
Save fcaldarelli/d4f80f831bee076556efac7d5f0ec060 to your computer and use it in GitHub Desktop.
Add properties to swift extensions
typealias IMG_VIEW_REQUESTS_TYPE = [ UIImageView : [String] ]
private struct AssociatedKey {
static var imgViewRequests = "imageCache_imgViewRequests"
}
var imgViewRequests : IMG_VIEW_REQUESTS_TYPE {
get {
return objc_getAssociatedObject(self, &AssociatedKey.imgViewRequests) as! SmartSingleton.IMG_VIEW_REQUESTS_TYPE
}
set(downloader) {
objc_setAssociatedObject(self, &AssociatedKey.imgViewRequests, downloader, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment