Latest 0.0.3
License MIT
Platforms ios 5.0, osx 10.6, requires ARC
Dependencies MYSRuntime
Frameworks Foundation

Quickly add properties to categories using runtime associations. Property names must follow the 3 letter prefix (e.g. mys_property) category naming convention in order for this to work.


In your Podfile, add this line:

pod "MYSCategoryProperties"


Add properties to your header file:

@interface NSString (Example) 
@property (nonatomic, copy  ) NSDate    *mys_typedAt;
@property (nonatomic, assign) NSInteger mys_firstSpaceIndex;

Import the header:

#import <MYSCategoryProperties.h>

Add @dynamic for each property in your implementation file:

@implementation NSString (Example)
@dynamic mys_typedAt;
@dynamic mys_firstSpaceIndex;

Call this method in + (void)load (which is called on each category of a class):

+ (void)load
    [MYSCategoryProperties setup:self];

And that’s it!

You can now use the properties like normal:

NSString *string = @"A string";
string.mys_typedAt = [NSDate date];
string.mys_firstSpaceIndex = 1;

NSLog(@"A string: "%@" that was typed at %@ has a space at %d", string, string.mys_typedAt, string.mys_firstSpaceIndex);


Please update and run the tests before submitting a pull request. Thanks.


Much inspiration and code taken from


Adam Kirk (@atomkirk)

Latest podspec

    "name": "MYSCategoryProperties",
    "version": "0.0.3",
    "summary": "Quickly add properties to categories using runtime associations.",
    "description": "                   Quickly add properties to categories using runtime associations.n                   * Only implements getters and setters for dynamic properties.n                   * Only implements setters for properties not marked as `readonly`.n                   * Names getters and setters automatically unless the property declaration specifies customer getter/setter names.n                   * It is **highly** recommended that you prefix your category methods with a 3 letter prefix (e.g. 'mys').n",
    "homepage": "",
    "license": "MIT",
    "authors": {
        "Adam Kirk": "[email protected]"
    "platforms": {
        "ios": "5.0",
        "osx": "10.6"
    "source": {
        "git": "",
        "tag": "0.0.3"
    "source_files": "MYSCategoryProperties/MYSCategoryProperties.{h,m}",
    "frameworks": "Foundation",
    "requires_arc": true,
    "dependencies": {
        "MYSRuntime": [
            "~> 0.0.2"

Pin It on Pinterest

Share This