Skip to content

Instantly share code, notes, and snippets.

@m1entus
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m1entus/b4aeec820405cb058d16 to your computer and use it in GitHub Desktop.
Save m1entus/b4aeec820405cb058d16 to your computer and use it in GitHub Desktop.
objc_setAssociatedObject.swift
var imageRequestOperationKey = "imageRequestOperationPointer"
let imageRequestOperationPointer = UnsafePointer<String>(COpaquePointer(&imageRequestOperationKey))
extension UIImageView {
func bw_imageRequestOperation() -> AFHTTPRequestOperation {
return objc_getAssociatedObject(self, imageRequestOperationPointer) as AFHTTPRequestOperation
}
func bw_setImageRequestOperation(operation :AFHTTPRequestOperation?) {
objc_setAssociatedObject(self, imageRequestOperationPointer, operation, UInt(OBJC_ASSOCIATION_RETAIN_NONATOMIC))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment