title: How do I respond to the user shaking an iPhone?
body: <p>Alright, so to get going with Objective-C (I'm usually just an HTML PhoneGap kinda guy), I made a simple Magic 8 ball app. I've got it right now so that when I touch the screen, the ball "shakes" and takes a random response and puts it in a label. What I want to do is when the iPhone itself is shaked, the text is updated too.</p>
  
  <p>Here's my MainView.m:</p>
  
  <pre><code>#import "MainView.h"
  
  @implementation MainView
  
  - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
   if (event.type == UIEventSubtypeMotionShake) {
    int rNumber = rand() % 26;
    switch (rNumber) {
                  case 0:
                      shook.text = @"Never";
                      break;
              ....25 more entries.....
                  default:
                      break;
             }
      }
   }
  
   - (IBAction)yesNo {
   [NSThread sleepForTimeInterval:0.75];
   int rNumber = rand() % 26;
   switch (rNumber) {
    case 0:
     result.text = @"Never";
     break;
    ........
    default:
    break;
   }
   }
  
   @end
  </code></pre>
  
  <p>and my MainView.h</p>
  
  <pre><code> #import &lt;UIKit/UIKit.h&gt;
   #import &lt;Foundation/Foundation.h&gt;
  
   @interface MainView : UIView &lt;UIAccelerometerDelegate&gt; {
       IBOutlet UILabel *result;
    IBOutlet UILabel *shook;
   }
  
   - (IBAction)yesNo;
   - (void)motionEnded;
  
   @end     
  </code></pre>
  
  <p>Obviously there's an error in there, I know that much, but where?!</p>