3

Xcode 4.6.1 with iOS 6.1. I'm using remote database with StackMob. Application first gives an error and after I click Play a few times, it runs fine and communicates with the server just fine. Not sure how to detect the problem and should it a concern?

I have the following exception Break Point setup:

enter image description here

The application runs and then stops at the following line: enter image description here

   NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"User" inManagedObjectContext:self.managedObjectContext];
    [fetchRequest setEntity:entity];

    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"email == %@", self.emailAddressField.text];
    [fetchRequest setPredicate:predicate];

    NSError *error = nil;
    NSArray *fetchedObjects = [[self managedObjectContext] executeFetchRequest:fetchRequest error:&error];

so I changed the line above to:

NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
        NSEntityDescription *entity = [NSEntityDescription entityForName:@"User" inManagedObjectContext:self.managedObjectContext];
        [fetchRequest setEntity:entity];

        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"username == %@", self.usernameField.text];
        [fetchRequest setPredicate:predicate];

        [managedObjectContext executeFetchRequest:fetchRequest onSuccess:^(NSArray *fetchedObjects)
            {

Now when I run the program, I get the following error:

enter image description here

with

enter image description here

so I click the play button enter image description here

and I get the following error:

enter image description here

and after I click play one more time, the Application continues to run as if nothing happened? Should I be concerned?

bryanmac
  • 38,941
  • 11
  • 91
  • 99
user1107173
  • 10,334
  • 16
  • 72
  • 117

2 Answers2

4

You can check what the exception is with a simple lldb command, once the debugger stops on the exception. Select the exception like in your thread 6 here:

enter image description here

And then if you are running on the simulator type:

po $eax

If you are running on the device:

po $r0  (for 32-bit)
po $x0  (for 64-bit)

You should get a description of the exception.

Jorge
  • 2,530
  • 1
  • 19
  • 28
1

You already had this code:

NSError *error = nil;
NSArray *fetchedObjects = 
    [[self managedObjectContext] executeFetchRequest:fetchRequest error:&error];

So all you need is to keep going (without the breakpoint) and allow the error to log itself:

if (!fetchedObjects)
    NSLog(@"%@", error.localizedDescription);
matt
  • 515,959
  • 87
  • 875
  • 1,141