Shake To…

On 15/10/2009, in Development, Source Code, Tips, iPhone, by Pelaez

This is a class I made to detect shakes. It’s really simple, you just create an object, initialize it, set a delegate, and it will send messages to the delegate when the movement change is significant, then your object can do whatever you want, like refreshing info or whatever.

Details:

  • Detects side shakes.
  • Has a mechanism to avoid sending multiple messages for one long shake.
  • Sensitivity can be edited easily.
  • It has it’s protocol, so you don’t have to add new methods to your receiver’s interface.
  • It uses #ifndef’s so it can be imported several times without causing errors for having the same class multiple times.
  • Only one can be working at the time (activating a new one will deactivate the previous working one).

You can get the class at my GitHub.

It will be updated eventually.

If you see any error or anything wrong, please send me an e-mail!

Tagged with:  

1 Response » to “Shake To…”

  1. DomMaiocchi says:

    Awesome! This will surely make things easier :)

Leave a Reply