Permalink
Browse files

New UIGestureRecognizer category and Xcode 4 fixes

* Added a UIGestureRecognizer category method that accepts a block to respond to the recognizer in place of the target/action style.
* Got the whole project building and running the tests properly in Xcode 4 (tested in GM2)
  • Loading branch information...
1 parent 694c192 commit d3de9295145179df6212376fd17967021c4ad3fc @neror committed Mar 8, 2011
@@ -0,0 +1,52 @@
+/*
+ The MIT License
+
+ Copyright (c) 2011 Free Time Studios and Nathan Eror
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ 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.
+*/
+
+#import "FTUtils+UIGestureRecognizer.h"
+#import <objc/runtime.h>
+
+@interface UIGestureRecognizer()
+
+- (void)handleAction:(UIGestureRecognizer *)recognizer;
+
+@end
+
+static char * kFTGestureActionKey = "ft_gestureAction";
+
+@implementation UIGestureRecognizer(FTBlockAdditions)
+
++ (id)recognizerWithAction:(FTUIGestureActionBlock)action {
+ id me = [[self class] alloc];
+ me = [me initWithTarget:me action:@selector(handleAction:)];
+ objc_setAssociatedObject(me, kFTGestureActionKey, action, OBJC_ASSOCIATION_COPY);
+ return [me autorelease];
+}
+
+- (void)handleAction:(UIGestureRecognizer *)recognizer {
+ [recognizer retain];
+ FTUIGestureActionBlock action = objc_getAssociatedObject(recognizer, kFTGestureActionKey);
+ action(recognizer);
+ [recognizer release];
+}
+
+@end
@@ -40,7 +40,7 @@ + (NSString *)displayName {
#pragma mark init and dealloc
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
- if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
+ if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
self.title = [[self class] displayName];
}
return self;
@@ -38,7 +38,7 @@ + (NSString *)displayName {
#pragma mark init and dealloc
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
- if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
+ if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
self.title = [[self class] displayName];
}
return self;

Large diffs are not rendered by default.

Oops, something went wrong.
File renamed without changes.
@@ -0,0 +1,31 @@
+/*
+ The MIT License
+
+ Copyright (c) 2011 Free Time Studios and Nathan Eror
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ 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.
+*/
+
+typedef void (^FTUIGestureActionBlock)(UIGestureRecognizer *recognizer);
+
+@interface UIGestureRecognizer(FTBlockAdditions)
+
++ (id)recognizerWithAction:(FTUIGestureActionBlock)action;
+
+@end
@@ -23,7 +23,7 @@ of this software and associated documentation files (the "Software"), to deal
*/
#import <SenTestingKit/SenTestingKit.h>
-#import "FTAnimationManager.h"
+#import <FTUtils/FTAnimation.h>
@interface TestFTAnimationManager : SenTestCase {
UIView *rootView;
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>en</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.freetimestudios.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>BNDL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+</dict>
+</plist>
@@ -0,0 +1,7 @@
+//
+// Prefix header for all source files of the 'UnitTests' target in the 'UnitTests' project
+//
+
+#ifdef __OBJC__
+ #import <UIKit/UIKit.h>
+#endif
@@ -0,0 +1,2 @@
+/* Localized versions of Info.plist keys */
+

0 comments on commit d3de929

Please sign in to comment.