Xcode 4.6.1 with iOS 6.1。我正在使用StackMob的远程数据库。应用程序首先出现错误,然后单击“播放”几次后,它运行正常并与服务器通信就好了。不确定如何检测问题,是否应该关注?
我有以下异常断点设置:
应用程序运行,然后在以下行停止:
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];
所以我将上面的一行改为:
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)
{
现在,当我运行程序时,出现以下错误:
与
所以我点击播放按钮
我收到以下错误:
在我再次单击播放后,应用程序继续运行,好像什么也没发生?我应该担心吗?
答案 0 :(得分:4)
一旦调试器停止异常,您就可以使用简单的lldb命令检查异常是什么。像在线程6中一样选择例外:
然后如果你在模拟器上运行类型:
po $eax
如果您在设备上运行:
po $r0 (for 32-bit)
po $x0 (for 64-bit)
您应该获得异常的描述。
答案 1 :(得分:1)
您已经拥有此代码:
NSError *error = nil;
NSArray *fetchedObjects =
[[self managedObjectContext] executeFetchRequest:fetchRequest error:&error];
所以你需要的是继续(没有断点)并允许错误记录自己:
if (!fetchedObjects)
NSLog(@"%@", error.localizedDescription);