Browse files

Minor changes to the gesture recognizer blocks category.

* Changed the association policy of the disabled property to OBJC_ASSOCIATION_RETAIN to avoid making an unnecessary copy.

* Changed the example to use the disabled property instead of just setting the actionBlock property to nil.

* Cleaned up the source file formatting to match the rest of the project.

Signed-off-by: Nathan Eror <bignate@gmail.com>
  • Loading branch information...
1 parent be6cd49 commit 481fe1214de37e5b69f9bc0fad8ee6a1850775e4 @neror committed Sep 1, 2011
View
24 Classes/FTUtils+UIGestureRecognizer.m
@@ -39,36 +39,36 @@ - (void)handleAction:(UIGestureRecognizer *)recognizer;
@implementation UIGestureRecognizer(FTBlockAdditions)
+ (id)recognizer {
- return [self recognizerWithActionBlock:nil];
+ return [self recognizerWithActionBlock:nil];
}
+ (id)recognizerWithActionBlock:(FTGestureActionBlock)action {
- id me = [[self class] alloc];
- me = [me initWithTarget:me action:@selector(handleAction:)];
- [me setActionBlock:action];
- return [me autorelease];
+ id me = [[self class] alloc];
+ me = [me initWithTarget:me action:@selector(handleAction:)];
+ [me setActionBlock:action];
+ return [me autorelease];
}
- (void)handleAction:(UIGestureRecognizer *)recognizer {
- if(self.actionBlock && !self.disabled) {
- self.actionBlock(recognizer);
- }
+ if(self.actionBlock && !self.disabled) {
+ self.actionBlock(recognizer);
+ }
}
- (FTGestureActionBlock)actionBlock {
- return objc_getAssociatedObject(self, kFTGestureActionKey);
+ return objc_getAssociatedObject(self, kFTGestureActionKey);
}
- (void)setActionBlock:(FTGestureActionBlock)actionBlock {
- objc_setAssociatedObject(self, kFTGestureActionKey, actionBlock, OBJC_ASSOCIATION_COPY);
+ objc_setAssociatedObject(self, kFTGestureActionKey, actionBlock, OBJC_ASSOCIATION_COPY);
}
- (BOOL)disabled {
- return [objc_getAssociatedObject(self, kFTGestureDisabledKey) boolValue];
+ return [objc_getAssociatedObject(self, kFTGestureDisabledKey) boolValue];
}
- (void)setDisabled:(BOOL)disabled {
- objc_setAssociatedObject(self, kFTGestureDisabledKey, [NSNumber numberWithBool:disabled], OBJC_ASSOCIATION_COPY);
+ objc_setAssociatedObject(self, kFTGestureDisabledKey, [NSNumber numberWithBool:disabled], OBJC_ASSOCIATION_RETAIN);
}
@end
View
2 Examples/GestureRecognizerBlocks.m
@@ -61,7 +61,7 @@ - (void)viewDidLoad {
[self.viewToAnimate addGestureRecognizer:thePinch];
UITapGestureRecognizer *doubleTap = [UITapGestureRecognizer recognizerWithActionBlock:^(id dTap) {
- thePinch.actionBlock = nil;
+ thePinch.disabled = !thePinch.disabled;
[UIView animateWithDuration:.25f animations:^{
self.viewToAnimate.transform = CGAffineTransformIdentity;
}];
View
13 FTUtils.xcodeproj/project.pbxproj
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 45;
+ objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
@@ -451,8 +451,11 @@
/* Begin PBXProject section */
0867D690FE84028FC02AAC07 /* Project object */ = {
isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0410;
+ };
buildConfigurationList = 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "FTUtils" */;
- compatibilityVersion = "Xcode 3.1";
+ compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
@@ -592,7 +595,6 @@
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.sdk/System/Library/Frameworks,
);
GCC_DYNAMIC_NO_PIC = NO;
- GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
@@ -652,7 +654,6 @@
HEADER_SEARCH_PATHS = Headers/;
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
OTHER_LDFLAGS = "-ObjC";
- PREBINDING = NO;
PROVISIONING_PROFILE = "";
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = iphoneos;
@@ -671,7 +672,6 @@
HEADER_SEARCH_PATHS = Headers/;
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
OTHER_LDFLAGS = "-ObjC";
- PREBINDING = NO;
PROVISIONING_PROFILE = "";
RUN_CLANG_STATIC_ANALYZER = YES;
SDKROOT = iphoneos;
@@ -752,7 +752,6 @@
"-ObjC",
"-all_load",
);
- PREBINDING = NO;
PRODUCT_NAME = FTAnimationExamples;
PROVISIONING_PROFILE = "";
SDKROOT = iphoneos;
@@ -766,7 +765,6 @@
CODE_SIGN_IDENTITY = "iPhone Distribution";
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
- GCC_ENABLE_FIX_AND_CONTINUE = NO;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/UIKit.framework/Headers/UIKit.h";
INFOPLIST_FILE = "FTAnimationExamples-Info.plist";
@@ -778,7 +776,6 @@
"-framework",
UIKit,
);
- PREBINDING = NO;
PRODUCT_NAME = FTAnimationExamples;
PROVISIONING_PROFILE = "";
SDKROOT = iphoneos;
View
10 Headers/FTUtils/FTUtils+UIGestureRecognizer.h
@@ -20,7 +20,7 @@
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
- */
+*/
#if NS_BLOCKS_AVAILABLE
@@ -80,9 +80,11 @@ typedef void (^FTGestureActionBlock)(id recognizer);
/**
A property indicating that the block should *not* be called when
- the recognizer fires. Useful if you need to temporarily disable an action
- but you still want the block to be around later on.
- */
+ the recognizer fires.
+
+ Useful if you need to temporarily disable an action but you still
+ want the block to be around later on.
+*/
@property (nonatomic, assign) BOOL disabled;
@end

0 comments on commit 481fe12

Please sign in to comment.