I do not understand what mean this style and are there any benefits for standard setter/getter?
- (UIViewController*)myVC {
return objc_getAssociatedObject(self, kMJPopupViewController);
}
- (void)setMyVC:(UIViewController *) myVC {
objc_setAssociatedObject(self, kMyVC, myVC, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
You can only have member variables -- which back "standard" properties' getters and setters -- in the main
@interface
and in the class extension (the category with no name). Using associated objects is especially useful in a class's category because it lets you pretend the class has a backing variable anyway.See also libextobjc, which has a synthesizeAssociation() macro, which makes it near trivial to add @properties inside categories.