diff --git a/TezButton/TezButton.h b/TezButton/TezButton.h index a2883b3..32c0bec 100644 --- a/TezButton/TezButton.h +++ b/TezButton/TezButton.h @@ -331,5 +331,6 @@ #pragma mark - Include data Button /** Incluging data button */ @interface IncludeDataButton : UIButton -@property (nonatomic, strong) NSDictionary* info; +- (void)setData:(id)data; +- (id)data; @end diff --git a/TezButton/TezButton.m b/TezButton/TezButton.m index 47d9d68..2bd030f 100644 --- a/TezButton/TezButton.m +++ b/TezButton/TezButton.m @@ -6,11 +6,13 @@ // #import "TezButton.h" +#import static const double DefaultMagnification = 1; static const CGFloat DefaultFontSize = 13; static const CGFloat DefaultCornerRadius = 8; static const UIRectCorner DefaultCornerOption = UIRectCornerAllCorners; +static void *DataKey = "DataKey"; #pragma mark - TezButton @interface TezButton() @@ -622,4 +624,13 @@ - (void) drawRect:(CGRect)rect { #pragma mark - Include data Button @implementation IncludeDataButton : UIButton +- (void)setData:(id)data { + objc_setAssociatedObject(self, DataKey, data, OBJC_ASSOCIATION_RETAIN); +} + +- (id)data { + id data = objc_getAssociatedObject(self, DataKey); + + return data; +} @end diff --git a/TezButtonExample/ViewController.m b/TezButtonExample/ViewController.m index e61e093..4d521fd 100644 --- a/TezButtonExample/ViewController.m +++ b/TezButtonExample/ViewController.m @@ -142,7 +142,7 @@ - (void)makeButtons { // Include Data option IncludeDataButton* includeDataBtn = [[IncludeDataButton alloc] initWithFrame:CGRectMake(originX, originY, self.view.frame.size.width/2 - 20*1.5, 60)]; - [includeDataBtn setInfo:[NSDictionary new]]; + [includeDataBtn setData:[NSDictionary new]]; [includeDataBtn setBackgroundColor:colorPink]; [includeDataBtn setTitleColor:colorWhite forState:UIControlStateNormal]; [includeDataBtn setTitle:@"Include data btn" forState:UIControlStateNormal];