Skip to content

Instantly share code, notes, and snippets.

@troyharris
Last active December 19, 2015 03:39

Revisions

  1. troyharris renamed this gist Aug 4, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. troyharris renamed this gist Aug 4, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. troyharris created this gist Jun 29, 2013.
    33 changes: 33 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    // THGridMenuItem+ProjectItem.h
    #import "THGridMenuItem.h"
    #import "Project.h"

    @interface THGridMenuItem (ProjectItem)

    @property (nonatomic, strong) Project *project;

    -(Project *)project;
    -(void)setProject:(Project *)project;

    @end

    // THGridMenuItem+ProjectItem.m

    #import "THGridMenuItem+ProjectItem.h"
    #import <objc/runtime.h>

    static char projectMenuItemKey;

    @implementation THGridMenuItem (ProjectItem)

    -(Project *)project {
    return objc_getAssociatedObject(self, &projectMenuItemKey);
    }

    -(void)setProject:(Project *)project {
    objc_setAssociatedObject(self, &projectMenuItemKey, project, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
    }



    @end