Last active
August 15, 2018 22:01
-
-
Save serhatsezer/dca59ba6bcafa7877950aeb518f8c135 to your computer and use it in GitHub Desktop.
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
| @interface UIImage (Caption) | |
| @property (nonatomic, copy) NSString *caption; | |
| @end | |
| // Implementation | |
| #import <objc/runtime.h> | |
| static const void *ImageCaptionKey = &ImageCaptionKey; | |
| @implementation UIImage (Caption) | |
| - (void)setCaption:(NSSting *)caption { | |
| objc_setAssociatedObject(self, ImageCaptionKey, caption, OBJC_ASSOCIATION_COPY_NONATOMIC); | |
| } | |
| - (NSString *)caption { | |
| return objc_getAssociatedObject(self, ImageCaptionKey); | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment