Skip to content

Instantly share code, notes, and snippets.

@tonycn
Created September 21, 2012 07:26
Show Gist options
  • Save tonycn/3760192 to your computer and use it in GitHub Desktop.
Save tonycn/3760192 to your computer and use it in GitHub Desktop.
objc runtime used to create dynamic attribute
- (NSString *)viewFrame1 {
return objc_getAssociatedObject(self, kUIViewAdditionsFrame1);
}
- (void)setViewFrame1:(NSString *)frameStr {
objc_setAssociatedObject(self, kUIViewAdditionsFrame1, frameStr, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
- (NSString *)viewFrame2 {
return objc_getAssociatedObject(self, kUIViewAdditionsFrame2);
}
- (void)setViewFrame2:(NSString *)frameStr {
objc_setAssociatedObject(self, kUIViewAdditionsFrame2, frameStr, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment