A tiny category, with a single method to send out a NSNotifiatication if a shake is detected :)
##Installation
###CocoaPods (preferred)
add the following to your Podfile
pod "DHCShakeNotifier"
###Manual
add contents of DHCShakeNotifier
to your project
##Usage
Clone/ download the repo and take a quick look at the demo.
-
import DHCShakeNotifier:
#import "UIWindow+DHCShakeRecognizer.h"
-
listen for shake notification by adding an NSNotification observer :
@implementation YourObject ... -(id)init{ if (self==[super init]) { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(methodThatIsCalledAfterShake) name:DHCSHakeNotificationName object:nil]; } return self; } ... -(void)methodThatIsCalledAfterShake{ NSLog(@"\"I have just been shaken\" - A martini after being ordered by James Bond"); } ... -(void)dealloc{ [[NSNotificationCenter defaultCenter] removeObserver:self name:DHCSHakeNotificationName object:nil]; } ... @end