Forked from kostiakoval/Associated-NSNumber.codesnippet
Created
July 3, 2014 14:45
-
-
Save pwblaine/074eee3e8ccfd5b93e09 to your computer and use it in GitHub Desktop.
Revisions
-
kostiakoval revised this gist
Mar 30, 2014 . 2 changed files with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.File renamed without changes. -
kostiakoval revised this gist
Mar 29, 2014 . 1 changed file with 26 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ // // NSObject+Assosiated.h // NSObject-Associated // // Created by Konstantin Koval on 29/03/14. // Copyright (c) 2014 Konstantin Koval. All rights reserved. // #import <Foundation/Foundation.h> @interface NSObject (AssociatedTest) @property (nonatomic, strong) NSString *name; @property (nonatomic, assign) id delegate; @end // Implementation #import "KKNSObject+Associated.h" @implementation NSObject (AssociatedTest) ASSOCIATED(name, setName, NSString *, OBJC_ASSOCIATION_RETAIN_NONATOMIC) ASSOCIATED(delegate, setDelegate, id, OBJC_ASSOCIATION_ASSIGN) @end -
kostiakoval revised this gist
Mar 29, 2014 . 2 changed files with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,8 @@ - (<#type#>)<#propertyName#> { return objc_getAssociatedObject(self, _cmd); } - (void)set<#propertyName#>:(<#type#>)object { objc_setAssociatedObject(self, @selector(<#propertyName#>), object, OBJC_ASSOCIATION_); } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,8 @@ - (<#type#>)<#propertyName#> { return [objc_getAssociatedObject(self, _cmd) <#NSNumberMethod#>]; } - (void)set<#propertyName#>:(<#type#>)object { objc_setAssociatedObject(self, @selector(<#propertyName#>), [NSNumber numberWith:object], OBJC_ASSOCIATION_); } -
kostiakoval renamed this gist
Mar 29, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
kostiakoval revised this gist
Mar 29, 2014 . 2 changed files with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.File renamed without changes. -
kostiakoval revised this gist
Mar 29, 2014 . 3 changed files with 36 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ - (<#type#>)<#propertyName#> { return objc_getAssociatedObject(self, _cmd); } - (void)set<#propertyName#>:(<#type#>)object { objc_setAssociatedObject(self, @selector(<#propertyName#>), object, OBJC_ASSOCIATION_); } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,4 +6,3 @@ { objc_setAssociatedObject(self, @selector(<#propertyName#>), [NSNumber numberWith:object], OBJC_ASSOCIATION_); } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ // // KKNSObject+Assosiated.h // NSObject-Associated // // Created by Konstantin Koval on 29/03/14. // Copyright (c) 2014 Konstantin Koval. All rights reserved. // /** * A macro that creates getter and setter for your assosiated object * * @param propertyName Getter funtion name * @param setter Setter funtion name * @param objc_AssociationPolicy Memory policy for assosiated object * * Available option: OBJC_ASSOCIATION_ASSIGN, OBJC_ASSOCIATION_RETAIN_NONATOMIC, OBJC_ASSOCIATION_COPY_NONATOMIC, OBJC_ASSOCIATION_RETAIN, OBJC_ASSOCIATION_COPY * */ #import <objc/runtime.h> #define ASSOCIATED(propertyName, setter, type, objc_AssociationPolicy)\ - (type)propertyName {\ return objc_getAssociatedObject(self, _cmd);\ }\ \ - (void)setter:(type)object\ {\ objc_setAssociatedObject(self, @selector(propertyName), object, objc_AssociationPolicy);\ } -
kostiakoval revised this gist
Mar 29, 2014 . 1 changed file with 9 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1,9 @@ - (<#type#>)<#propertyName#> { return [objc_getAssociatedObject(self, _cmd) <#NSNumberMethod#>]; } - (void)set<#propertyName#>:(<#type#>)object { objc_setAssociatedObject(self, @selector(<#propertyName#>), [NSNumber numberWith:object], OBJC_ASSOCIATION_); } -
kostiakoval created this gist
Mar 29, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ _