Repository: jakemarsh/JMWhenTapped
Branch: master
Commit: 33b37f8378ad
Files: 15
Total size: 26.0 KB
Directory structure:
gitextract_fzh8da9o/
├── .gitignore
├── JMWhenTapped/
│ ├── JMWhenTapped.h
│ ├── UIView+WhenTappedBlocks.h
│ └── UIView+WhenTappedBlocks.m
├── JMWhenTappedDemo/
│ ├── JMWhenTappedDemo/
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── DemoViewController.h
│ │ ├── DemoViewController.m
│ │ ├── JMWhenTappedDemo-Info.plist
│ │ ├── JMWhenTappedDemo-Prefix.pch
│ │ ├── en.lproj/
│ │ │ └── InfoPlist.strings
│ │ └── main.m
│ └── JMWhenTappedDemo.xcodeproj/
│ └── project.pbxproj
├── MIT-LICENSE
└── README.markdown
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
# Mac OS X
*.DS_Store
*.psd
# Xcode
build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
*.xcworkspace
!default.xcworkspace
xcuserdata
profile
*.moved-aside
# Generated files
build/
*.[oa]
*.pyc
# Backup files
*~.nib
/ graphics/
================================================
FILE: JMWhenTapped/JMWhenTapped.h
================================================
//
// JMWhenTapped.h
// JMWhenTappedDemo
//
// Created by Jake Marsh on 4/27/11.
// Copyright 2011 Rubber Duck Software. All rights reserved.
//
#import "UIView+WhenTappedBlocks.h"
================================================
FILE: JMWhenTapped/UIView+WhenTappedBlocks.h
================================================
//
// UIView+WhenTappedBlocks.h
//
// Created by Jake Marsh on 3/7/11.
// Copyright 2011 Rubber Duck Software. All rights reserved.
//
#if NS_BLOCKS_AVAILABLE
#import <UIKit/UIKit.h>
typedef void (^JMWhenTappedBlock)();
@interface UIView (JMWhenTappedBlocks) <UIGestureRecognizerDelegate>
- (void)whenTapped:(JMWhenTappedBlock)block;
- (void)whenDoubleTapped:(JMWhenTappedBlock)block;
- (void)whenTwoFingerTapped:(JMWhenTappedBlock)block;
- (void)whenTouchedDown:(JMWhenTappedBlock)block;
- (void)whenTouchedUp:(JMWhenTappedBlock)block;
@end
#endif
================================================
FILE: JMWhenTapped/UIView+WhenTappedBlocks.m
================================================
//
// UIView+WhenTappedBlocks.m
//
// Created by Jake Marsh on 3/7/11.
// Copyright 2011 Rubber Duck Software. All rights reserved.
//
#if NS_BLOCKS_AVAILABLE
#import "UIView+WhenTappedBlocks.h"
#import <objc/runtime.h>
@interface UIView (JMWhenTappedBlocks_Private)
- (void)runBlockForKey:(void *)blockKey;
- (void)setBlock:(JMWhenTappedBlock)block forKey:(void *)blockKey;
- (UITapGestureRecognizer*)addTapGestureRecognizerWithTaps:(NSUInteger) taps touches:(NSUInteger) touches selector:(SEL) selector;
- (void) addRequirementToSingleTapsRecognizer:(UIGestureRecognizer*) recognizer;
- (void) addRequiredToDoubleTapsRecognizer:(UIGestureRecognizer*) recognizer;
@end
@implementation UIView (JMWhenTappedBlocks)
static char kWhenTappedBlockKey;
static char kWhenDoubleTappedBlockKey;
static char kWhenTwoFingerTappedBlockKey;
static char kWhenTouchedDownBlockKey;
static char kWhenTouchedUpBlockKey;
#pragma mark -
#pragma mark Set blocks
- (void)runBlockForKey:(void *)blockKey {
JMWhenTappedBlock block = objc_getAssociatedObject(self, blockKey);
if (block) block();
}
- (void)setBlock:(JMWhenTappedBlock)block forKey:(void *)blockKey {
self.userInteractionEnabled = YES;
objc_setAssociatedObject(self, blockKey, block, OBJC_ASSOCIATION_COPY_NONATOMIC);
}
#pragma mark -
#pragma mark When Tapped
- (void)whenTapped:(JMWhenTappedBlock)block {
UITapGestureRecognizer* gesture = [self addTapGestureRecognizerWithTaps:1 touches:1 selector:@selector(viewWasTapped)];
[self addRequiredToDoubleTapsRecognizer:gesture];
[self setBlock:block forKey:&kWhenTappedBlockKey];
}
- (void)whenDoubleTapped:(JMWhenTappedBlock)block {
UITapGestureRecognizer* gesture = [self addTapGestureRecognizerWithTaps:2 touches:1 selector:@selector(viewWasDoubleTapped)];
[self addRequirementToSingleTapsRecognizer:gesture];
[self setBlock:block forKey:&kWhenDoubleTappedBlockKey];
}
- (void)whenTwoFingerTapped:(JMWhenTappedBlock)block {
[self addTapGestureRecognizerWithTaps:1 touches:2 selector:@selector(viewWasTwoFingerTapped)];
[self setBlock:block forKey:&kWhenTwoFingerTappedBlockKey];
}
- (void)whenTouchedDown:(JMWhenTappedBlock)block {
[self setBlock:block forKey:&kWhenTouchedDownBlockKey];
}
- (void)whenTouchedUp:(JMWhenTappedBlock)block {
[self setBlock:block forKey:&kWhenTouchedUpBlockKey];
}
#pragma mark -
#pragma mark Callbacks
- (void)viewWasTapped {
[self runBlockForKey:&kWhenTappedBlockKey];
}
- (void)viewWasDoubleTapped {
[self runBlockForKey:&kWhenDoubleTappedBlockKey];
}
- (void)viewWasTwoFingerTapped {
[self runBlockForKey:&kWhenTwoFingerTappedBlockKey];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesBegan:touches withEvent:event];
[self runBlockForKey:&kWhenTouchedDownBlockKey];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
[super touchesEnded:touches withEvent:event];
[self runBlockForKey:&kWhenTouchedUpBlockKey];
}
#pragma mark -
#pragma mark Helpers
- (UITapGestureRecognizer*)addTapGestureRecognizerWithTaps:(NSUInteger)taps touches:(NSUInteger)touches selector:(SEL)selector {
UITapGestureRecognizer* tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:selector];
tapGesture.delegate = self;
tapGesture.numberOfTapsRequired = taps;
tapGesture.numberOfTouchesRequired = touches;
[self addGestureRecognizer:tapGesture];
return tapGesture;
}
- (void) addRequirementToSingleTapsRecognizer:(UIGestureRecognizer*) recognizer {
for (UIGestureRecognizer* gesture in [self gestureRecognizers]) {
if ([gesture isKindOfClass:[UITapGestureRecognizer class]]) {
UITapGestureRecognizer* tapGesture = (UITapGestureRecognizer*) gesture;
if (tapGesture.numberOfTouchesRequired == 1 && tapGesture.numberOfTapsRequired == 1) {
[tapGesture requireGestureRecognizerToFail:recognizer];
}
}
}
}
- (void) addRequiredToDoubleTapsRecognizer:(UIGestureRecognizer*) recognizer {
for (UIGestureRecognizer* gesture in [self gestureRecognizers]) {
if ([gesture isKindOfClass:[UITapGestureRecognizer class]]) {
UITapGestureRecognizer* tapGesture = (UITapGestureRecognizer*) gesture;
if (tapGesture.numberOfTouchesRequired == 2 && tapGesture.numberOfTapsRequired == 1) {
[recognizer requireGestureRecognizerToFail:tapGesture];
}
}
}
}
@end
#endif
================================================
FILE: JMWhenTappedDemo/JMWhenTappedDemo/AppDelegate.h
================================================
//
// JMWhenTappedDemoAppDelegate.h
// JMWhenTappedDemo
//
// Created by Jake Marsh on 4/27/11.
// Copyright 2011 Rubber Duck Software. All rights reserved.
//
#import <UIKit/UIKit.h>
@class DemoViewController;
@interface AppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *_window;
DemoViewController *_viewController;
}
@end
================================================
FILE: JMWhenTappedDemo/JMWhenTappedDemo/AppDelegate.m
================================================
//
// JMWhenTappedDemoAppDelegate.m
// JMWhenTappedDemo
//
// Created by Jake Marsh on 4/27/11.
// Copyright 2011 Rubber Duck Software. All rights reserved.
//
#import "AppDelegate.h"
#import "DemoViewController.h"
@implementation AppDelegate
- (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
_viewController = [[DemoViewController alloc] init];
_window.rootViewController = _viewController;
[_window makeKeyAndVisible];
return YES;
}
@end
================================================
FILE: JMWhenTappedDemo/JMWhenTappedDemo/DemoViewController.h
================================================
//
// JMWhenTappedDemoViewController.h
// JMWhenTappedDemo
//
// Created by Jake Marsh on 4/27/11.
// Copyright 2011 Rubber Duck Software. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface DemoViewController : UIViewController
@end
================================================
FILE: JMWhenTappedDemo/JMWhenTappedDemo/DemoViewController.m
================================================
//
// JMWhenTappedDemoViewController.m
// JMWhenTappedDemo
//
// Created by Jake Marsh on 4/27/11.
// Copyright 2011 Rubber Duck Software. All rights reserved.
//
#import "DemoViewController.h"
#import "JMWhenTapped.h"
@interface DemoViewController ()
@property (strong, nonatomic) UIView *view1;
@property (strong, nonatomic) UIView *view2;
@end
@implementation DemoViewController
@synthesize view1 = _view1;
@synthesize view2 = _view2;
- (void) loadView {
[super loadView];
self.view1 = [[UIView alloc] initWithFrame:CGRectMake(20.0, 20.0, 100.0, 100.0)];
self.view1.backgroundColor = [UIColor redColor];
[self.view addSubview:self.view1];
[self.view1 whenTapped:^{
UIAlertView *a = [[UIAlertView alloc] initWithTitle:@"Tapped!"
message:@"You tapped view1! Congratulations!"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[a show];
}];
[self.view1 whenDoubleTapped:^{
UIAlertView *a = [[UIAlertView alloc] initWithTitle:@"Double tapped!"
message:@"You double tapped view1! Congratulations!"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[a show];
}];
[self.view1 whenTwoFingerTapped:^{
UIAlertView *a = [[UIAlertView alloc] initWithTitle:@"Two finger tapped!"
message:@"You two finger tapped view1! Congratulations!"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[a show];
}];
self.view2 = [[UIView alloc] initWithFrame:CGRectMake(140.0, 20.0, 100.0, 100.0)];
self.view2.backgroundColor = [UIColor blueColor];
[self.view addSubview:self.view2];
__block DemoViewController *safeSelf = self;
[self.view2 whenTouchedDown:^{
safeSelf.view2.backgroundColor = [UIColor yellowColor];
}];
[self.view2 whenTouchedUp:^{
safeSelf.view2.backgroundColor = [UIColor blueColor];
UIAlertView *a = [[UIAlertView alloc] initWithTitle:@"Tapped!"
message:@"You tapped view2! Congratulations!"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[a show];
}];
}
#pragma mark Cleanup Methods
- (void) viewDidUnload {
[super viewDidUnload];
}
- (void) didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
@end
================================================
FILE: JMWhenTappedDemo/JMWhenTappedDemo/JMWhenTappedDemo-Info.plist
================================================
<?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>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.rubberducksoft.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
================================================
FILE: JMWhenTappedDemo/JMWhenTappedDemo/JMWhenTappedDemo-Prefix.pch
================================================
//
// Prefix header for all source files of the 'JMWhenTappedDemo' target in the 'JMWhenTappedDemo' project
//
#import <Availability.h>
#ifndef __IPHONE_3_0
#warning "This project uses features only available in iPhone SDK 3.0 and later."
#endif
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
================================================
FILE: JMWhenTappedDemo/JMWhenTappedDemo/en.lproj/InfoPlist.strings
================================================
/* Localized versions of Info.plist keys */
================================================
FILE: JMWhenTappedDemo/JMWhenTappedDemo/main.m
================================================
//
// main.m
// JMWhenTappedDemo
//
// Created by Jake Marsh on 4/27/11.
// Copyright 2011 Rubber Duck Software. All rights reserved.
//
#import <UIKit/UIKit.h>
int main(int argc, char *argv[]) {
@autoreleasepool {
int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");
return retVal;
}
}
================================================
FILE: JMWhenTappedDemo/JMWhenTappedDemo.xcodeproj/project.pbxproj
================================================
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
301AA693136ADFB000B2BB5C /* UIView+WhenTappedBlocks.m in Sources */ = {isa = PBXBuildFile; fileRef = 301AA692136ADFB000B2BB5C /* UIView+WhenTappedBlocks.m */; };
309F988F136899270030817E /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 309F988E136899270030817E /* UIKit.framework */; };
309F9891136899270030817E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 309F9890136899270030817E /* Foundation.framework */; };
309F9893136899270030817E /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 309F9892136899270030817E /* CoreGraphics.framework */; };
309F9899136899270030817E /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 309F9897136899270030817E /* InfoPlist.strings */; };
309F989C136899270030817E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 309F989B136899270030817E /* main.m */; };
309F989F136899270030817E /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 309F989E136899270030817E /* AppDelegate.m */; };
309F98A5136899270030817E /* DemoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 309F98A4136899270030817E /* DemoViewController.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
301AA692136ADFB000B2BB5C /* UIView+WhenTappedBlocks.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+WhenTappedBlocks.m"; sourceTree = "<group>"; };
309F988A136899270030817E /* JMWhenTappedDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = JMWhenTappedDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
309F988E136899270030817E /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
309F9890136899270030817E /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
309F9892136899270030817E /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
309F9896136899270030817E /* JMWhenTappedDemo-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "JMWhenTappedDemo-Info.plist"; sourceTree = "<group>"; };
309F9898136899270030817E /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
309F989A136899270030817E /* JMWhenTappedDemo-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "JMWhenTappedDemo-Prefix.pch"; sourceTree = "<group>"; };
309F989B136899270030817E /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
309F989D136899270030817E /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
309F989E136899270030817E /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
309F98A3136899270030817E /* DemoViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DemoViewController.h; sourceTree = "<group>"; };
309F98A4136899270030817E /* DemoViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DemoViewController.m; sourceTree = "<group>"; };
309F98B113689AE20030817E /* UIView+WhenTappedBlocks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+WhenTappedBlocks.h"; sourceTree = "<group>"; };
309F98B513689AFA0030817E /* JMWhenTapped.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JMWhenTapped.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
309F9887136899270030817E /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
309F988F136899270030817E /* UIKit.framework in Frameworks */,
309F9891136899270030817E /* Foundation.framework in Frameworks */,
309F9893136899270030817E /* CoreGraphics.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
309F987F136899270030817E = {
isa = PBXGroup;
children = (
309F9894136899270030817E /* JMWhenTappedDemo */,
309F988D136899270030817E /* Frameworks */,
309F988B136899270030817E /* Products */,
);
sourceTree = "<group>";
};
309F988B136899270030817E /* Products */ = {
isa = PBXGroup;
children = (
309F988A136899270030817E /* JMWhenTappedDemo.app */,
);
name = Products;
sourceTree = "<group>";
};
309F988D136899270030817E /* Frameworks */ = {
isa = PBXGroup;
children = (
309F988E136899270030817E /* UIKit.framework */,
309F9890136899270030817E /* Foundation.framework */,
309F9892136899270030817E /* CoreGraphics.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
309F9894136899270030817E /* JMWhenTappedDemo */ = {
isa = PBXGroup;
children = (
309F98AE13689AE20030817E /* JMWhenTapped */,
309F989D136899270030817E /* AppDelegate.h */,
309F989E136899270030817E /* AppDelegate.m */,
309F98A3136899270030817E /* DemoViewController.h */,
309F98A4136899270030817E /* DemoViewController.m */,
309F9895136899270030817E /* Supporting Files */,
);
path = JMWhenTappedDemo;
sourceTree = "<group>";
};
309F9895136899270030817E /* Supporting Files */ = {
isa = PBXGroup;
children = (
309F9896136899270030817E /* JMWhenTappedDemo-Info.plist */,
309F9897136899270030817E /* InfoPlist.strings */,
309F989A136899270030817E /* JMWhenTappedDemo-Prefix.pch */,
309F989B136899270030817E /* main.m */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
309F98AE13689AE20030817E /* JMWhenTapped */ = {
isa = PBXGroup;
children = (
309F98B113689AE20030817E /* UIView+WhenTappedBlocks.h */,
301AA692136ADFB000B2BB5C /* UIView+WhenTappedBlocks.m */,
309F98B513689AFA0030817E /* JMWhenTapped.h */,
);
name = JMWhenTapped;
path = ../../JMWhenTapped;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
309F9889136899270030817E /* JMWhenTappedDemo */ = {
isa = PBXNativeTarget;
buildConfigurationList = 309F98AB136899270030817E /* Build configuration list for PBXNativeTarget "JMWhenTappedDemo" */;
buildPhases = (
309F9886136899270030817E /* Sources */,
309F9887136899270030817E /* Frameworks */,
309F9888136899270030817E /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = JMWhenTappedDemo;
productName = JMWhenTappedDemo;
productReference = 309F988A136899270030817E /* JMWhenTappedDemo.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
309F9881136899270030817E /* Project object */ = {
isa = PBXProject;
attributes = {
ORGANIZATIONNAME = "Rubber Duck Software";
};
buildConfigurationList = 309F9884136899270030817E /* Build configuration list for PBXProject "JMWhenTappedDemo" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 309F987F136899270030817E;
productRefGroup = 309F988B136899270030817E /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
309F9889136899270030817E /* JMWhenTappedDemo */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
309F9888136899270030817E /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
309F9899136899270030817E /* InfoPlist.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
309F9886136899270030817E /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
309F989C136899270030817E /* main.m in Sources */,
309F989F136899270030817E /* AppDelegate.m in Sources */,
309F98A5136899270030817E /* DemoViewController.m in Sources */,
301AA693136ADFB000B2BB5C /* UIView+WhenTappedBlocks.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
309F9897136899270030817E /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
309F9898136899270030817E /* en */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
309F98A9136899270030817E /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = DEBUG;
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_VERSION = com.apple.compilers.llvmgcc42;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
SDKROOT = iphoneos;
};
name = Debug;
};
309F98AA136899270030817E /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_VERSION = com.apple.compilers.llvmgcc42;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
SDKROOT = iphoneos;
};
name = Release;
};
309F98AC136899270030817E /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "JMWhenTappedDemo/JMWhenTappedDemo-Prefix.pch";
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_FILE = "JMWhenTappedDemo/JMWhenTappedDemo-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
WRAPPER_EXTENSION = app;
};
name = Debug;
};
309F98AD136899270030817E /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = YES;
COPY_PHASE_STRIP = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "JMWhenTappedDemo/JMWhenTappedDemo-Prefix.pch";
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
INFOPLIST_FILE = "JMWhenTappedDemo/JMWhenTappedDemo-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
WRAPPER_EXTENSION = app;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
309F9884136899270030817E /* Build configuration list for PBXProject "JMWhenTappedDemo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
309F98A9136899270030817E /* Debug */,
309F98AA136899270030817E /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
309F98AB136899270030817E /* Build configuration list for PBXNativeTarget "JMWhenTappedDemo" */ = {
isa = XCConfigurationList;
buildConfigurations = (
309F98AC136899270030817E /* Debug */,
309F98AD136899270030817E /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 309F9881136899270030817E /* Project object */;
}
================================================
FILE: MIT-LICENSE
================================================
Copyright (c) 2012 Jake Marsh and other contributors.
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.
================================================
FILE: README.markdown
================================================
## What is it?
`JMWhenTapped` is a simple little syntactical-sugar addition to all `UIView` objects, as well as any class that inherits from `UIView`. It allows you to assign touch-up, touch-down, tapped (touched down then up), double taps and two finger taps actions to a `UIView` object using a convenient blocks-style syntax. (Examples shown below).
## Installation
Clone the repo. Add the `JMWhenTapped` folder to your iOS 4 project. `#import "JMWhenTapped.h"` wherever you'd like to use the syntax.
## Examples & Usage
Use it like this:
[myView whenTapped:^{
NSLog(@"I was tapped!");
}];
Or like this:
[myView whenTouchedDown:^{
NSLog(@"I was touched down!");
}];
And also like this:
[myView whenTouchedUp:^{
NSLog(@"I was touched up!");
}];
This works the same way with double tap and two finger taps.
## The Different Actions
The `whenTapped:` method should be used in cases where you simply want something to happen when the user taps on a view (i.e. you are concerned with performing some action when their finger is down then up, like changing to a "pressed" state.)
The `whenDoubleTapped:` method should be used when you want to check for double taps on your view.
The `whenTwoFingerTapped:` method should be used when you want to check for single taps made with two fingers (like in Maps.app).
The `whenTouchedDown:` method should be used when you want to trigger some action when the user touches down on your view.
The `whenTouchedUp:` method should be used when you want to trigger some action when the user touches up on your view.
## Demo
Included in this repo is a demo Xcode project that illustrates a quick example of how to use `JMWhenTapped`.
gitextract_fzh8da9o/ ├── .gitignore ├── JMWhenTapped/ │ ├── JMWhenTapped.h │ ├── UIView+WhenTappedBlocks.h │ └── UIView+WhenTappedBlocks.m ├── JMWhenTappedDemo/ │ ├── JMWhenTappedDemo/ │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── DemoViewController.h │ │ ├── DemoViewController.m │ │ ├── JMWhenTappedDemo-Info.plist │ │ ├── JMWhenTappedDemo-Prefix.pch │ │ ├── en.lproj/ │ │ │ └── InfoPlist.strings │ │ └── main.m │ └── JMWhenTappedDemo.xcodeproj/ │ └── project.pbxproj ├── MIT-LICENSE └── README.markdown
SYMBOL INDEX (1 symbols across 1 files)
FILE: JMWhenTappedDemo/JMWhenTappedDemo/AppDelegate.h
function interface (line 13) | interface AppDelegate : NSObject <UIApplicationDelegate> {
Condensed preview — 15 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (29K chars).
[
{
"path": ".gitignore",
"chars": 309,
"preview": "# Mac OS X\n*.DS_Store\n*.psd\n\n# Xcode\nbuild/*\n*.pbxuser\n!default.pbxuser\n*.mode1v3\n!default.mode1v3\n*.mode2v3\n!default.mo"
},
{
"path": "JMWhenTapped/JMWhenTapped.h",
"chars": 186,
"preview": "//\n// JMWhenTapped.h\n// JMWhenTappedDemo\n//\n// Created by Jake Marsh on 4/27/11.\n// Copyright 2011 Rubber Duck Softw"
},
{
"path": "JMWhenTapped/UIView+WhenTappedBlocks.h",
"chars": 559,
"preview": "//\n// UIView+WhenTappedBlocks.h\n//\n// Created by Jake Marsh on 3/7/11.\n// Copyright 2011 Rubber Duck Software. All ri"
},
{
"path": "JMWhenTapped/UIView+WhenTappedBlocks.m",
"chars": 4523,
"preview": "//\n// UIView+WhenTappedBlocks.m\n//\n// Created by Jake Marsh on 3/7/11.\n// Copyright 2011 Rubber Duck Software. All ri"
},
{
"path": "JMWhenTappedDemo/JMWhenTappedDemo/AppDelegate.h",
"chars": 343,
"preview": "//\n// JMWhenTappedDemoAppDelegate.h\n// JMWhenTappedDemo\n//\n// Created by Jake Marsh on 4/27/11.\n// Copyright 2011 Ru"
},
{
"path": "JMWhenTappedDemo/JMWhenTappedDemo/AppDelegate.m",
"chars": 596,
"preview": "//\n// JMWhenTappedDemoAppDelegate.m\n// JMWhenTappedDemo\n//\n// Created by Jake Marsh on 4/27/11.\n// Copyright 2011 Ru"
},
{
"path": "JMWhenTappedDemo/JMWhenTappedDemo/DemoViewController.h",
"chars": 247,
"preview": "//\n// JMWhenTappedDemoViewController.h\n// JMWhenTappedDemo\n//\n// Created by Jake Marsh on 4/27/11.\n// Copyright 2011"
},
{
"path": "JMWhenTappedDemo/JMWhenTappedDemo/DemoViewController.m",
"chars": 2919,
"preview": "//\n// JMWhenTappedDemoViewController.m\n// JMWhenTappedDemo\n//\n// Created by Jake Marsh on 4/27/11.\n// Copyright 2011"
},
{
"path": "JMWhenTappedDemo/JMWhenTappedDemo/JMWhenTappedDemo-Info.plist",
"chars": 1138,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "JMWhenTappedDemo/JMWhenTappedDemo/JMWhenTappedDemo-Prefix.pch",
"chars": 331,
"preview": "//\n// Prefix header for all source files of the 'JMWhenTappedDemo' target in the 'JMWhenTappedDemo' project\n//\n\n#import "
},
{
"path": "JMWhenTappedDemo/JMWhenTappedDemo/en.lproj/InfoPlist.strings",
"chars": 45,
"preview": "/* Localized versions of Info.plist keys */\n\n"
},
{
"path": "JMWhenTappedDemo/JMWhenTappedDemo/main.m",
"chars": 314,
"preview": "//\n// main.m\n// JMWhenTappedDemo\n//\n// Created by Jake Marsh on 4/27/11.\n// Copyright 2011 Rubber Duck Software. All"
},
{
"path": "JMWhenTappedDemo/JMWhenTappedDemo.xcodeproj/project.pbxproj",
"chars": 12346,
"preview": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 46;\n\tobjects = {\n\n/* Begin PBXBuildFile section *"
},
{
"path": "MIT-LICENSE",
"chars": 1077,
"preview": "Copyright (c) 2012 Jake Marsh and other contributors.\n\nPermission is hereby granted, free of charge, to any person obtai"
},
{
"path": "README.markdown",
"chars": 1700,
"preview": "## What is it?\n\n`JMWhenTapped` is a simple little syntactical-sugar addition to all `UIView` objects, as well as any cla"
}
]
About this extraction
This page contains the full source code of the jakemarsh/JMWhenTapped GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 15 files (26.0 KB), approximately 7.8k tokens, and a symbol index with 1 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.