title: Detecting # of Core Data objects in motionEnded:?
body: <p>I'm trying to detect the amount of objects I have in Core Data when the user shakes the device. When I try and call a NSFetchRequest inside of motionEnded:, the simulator crashes with an unknown error at main. </p>
  
  <p>Is doing a fetch like this inside of motionEnded: possible?  </p>
  
  <p>The code I have so far: </p>
  
  <pre><code>- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
  {
          // see if we have albums to upload
  
          NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
  
          NSEntityDescription *entity = [NSEntityDescription entityForName:@"Groups" inManagedObjectContext:managedObjectContext];
  
          [fetchRequest setEntity:entity];
  
          NSUInteger group_count = [managedObjectContext countForFetchRequest:fetchRequest error:nil];
  
          if (group_count == 0)
          {
              // show alertview
          }
          else
          {
              // show another alertview
          }
  
  }
  </code></pre>