Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andy LaVoy
committed
Oct 17, 2013
1 parent
e4e909d
commit 7dc6af1
Showing
10 changed files
with
89 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// UIGestureRecognizer+ALActionBlocks.h | ||
// ALActionBlocks | ||
// | ||
// Created by Andy LaVoy on 10/17/13. | ||
// Copyright (c) 2013 Andy LaVoy. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
#import "ALActionBlock.h" | ||
|
||
@interface UIGestureRecognizer (ALActionBlocks) | ||
|
||
- (instancetype)initWithBlock:(ALActionBlock)actionBlock; | ||
- (void)setBlock:(ALActionBlock)actionBlock; | ||
|
||
@end |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// UIGestureRecognizer+ALActionBlocks.m | ||
// ALActionBlocks | ||
// | ||
// Created by Andy LaVoy on 10/17/13. | ||
// Copyright (c) 2013 Andy LaVoy. All rights reserved. | ||
// | ||
|
||
#import "UIGestureRecognizer+ALActionBlocks.h" | ||
#import "ALActionBlockWrapper.h" | ||
#import <objc/runtime.h> | ||
|
||
@implementation UIGestureRecognizer (ALActionBlocks) | ||
|
||
|
||
- (instancetype)initWithBlock:(ALActionBlock)actionBlock { | ||
UIGestureRecognizer *gestureRecognizer = [[[self class] alloc] init]; | ||
[gestureRecognizer setBlock:actionBlock]; | ||
return gestureRecognizer; | ||
} | ||
|
||
|
||
- (void)setBlock:(ALActionBlock)actionBlock { | ||
NSMutableArray *actionBlocksArray = [self actionBlocksArray]; | ||
|
||
ALActionBlockWrapper *blockActionWrapper = [[ALActionBlockWrapper alloc] init]; | ||
blockActionWrapper.actionBlock = actionBlock; | ||
[actionBlocksArray addObject:blockActionWrapper]; | ||
|
||
[self addTarget:blockActionWrapper action:@selector(invokeBlock:)]; | ||
} | ||
|
||
|
||
- (NSMutableArray *)actionBlocksArray { | ||
NSMutableArray *actionBlocksArray = objc_getAssociatedObject(self, &ALActionBlocksArray); | ||
if (!actionBlocksArray) { | ||
actionBlocksArray = [NSMutableArray array]; | ||
objc_setAssociatedObject(self, &ALActionBlocksArray, actionBlocksArray, OBJC_ASSOCIATION_RETAIN); | ||
} | ||
return actionBlocksArray; | ||
} | ||
|
||
@end |
This file contains 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 characters
This file contains 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 characters