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.
Is doing a fetch like this inside of motionEnded: possible?
The code I have so far:
- (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
}
}