Skip to content

Latest commit

 

History

History
69 lines (45 loc) · 1.52 KB

README.md

File metadata and controls

69 lines (45 loc) · 1.52 KB

YSDynamicProperties

Cocoapods

Dynamic Accessors for Category Properties

##The Problem

Tired of the Runtime objc_getAssociatedObject objc_setAssociatedObject to the Category implementation method of @Dynamic Property?

Link Blog Post

##Installation

YSDynamicProperties is available through CocoaPods, to install it simply add the following line to your Podfile:

pod 'YSDynamicProperties'

##Usage

  1. Add #import "NSObject+YSDynamicProperties.h" to Category file.
  2. Define properties in .h Category file.
  3. Add @dynamic statement for each property in .m file.

Example:

@interface Superman (YSKit)
@property (strong, nonatomic) UIColor *ys_ShirtColor;
@property (strong, nonatomic) NSArray *ys_Weapons;
@end
#import "NSObject+YSDynamicProperties.h"

@implementation Superman (YSKit)
@dynamic ys_ShirtColor, ys_Weapons;

+ (void)load
{
  [self implementDynamicPropertyAccessors];
}

@end

License

This code is distributed under the terms and conditions of the MIT license.

Donate

You can support me by:

:-)

Contact