ios - 更新到 iOS sdk 8.0 后应用程序崩溃

标签 ios ios7 ios8

更新至 iOS SDK 8.0。

应用因错误而崩溃

[PFInternalUtils assertValidClassForQuery:] at PFInternalUtils.m:372

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Cannot do a comparison query for type: (null)'
*** First throw call stack:
(
  0   CoreFoundation                      0x032d6df6 __exceptionPreprocess + 182
1   libobjc.A.dylib                     0x02f60a97 objc_exception_throw + 44
2   CoreFoundation                      0x032d6d1d +[NSException raise:format:] + 141
3                                0x000e60b2 +[PFInternalUtils assertValidClassForQuery:] + 324
4                                 0x000ce3cb -[PFQuery whereKey:equalTo:] + 91
5                                 0x000b7391 -[InboxViewController retrieveMessages] + 193
6                                 0x000b624c -[InboxViewController viewWillAppear:] + 236
7   UIKit                               0x01aa614f -[UIViewController _setViewAppearState:isAnimating:] + 545
8   UIKit                               0x01aa66ca -[UIViewController __viewWillAppear:] + 148
9   UIKit                               0x01ad8389 -[UINavigationController _startTransition:fromViewController:toViewController:] + 931
10  UIKit                               0x01ad8fdb -[UINavigationController _startDeferredTransitionIfNeeded:] + 669
11  UIKit                               0x01ad9c52 -[UINavigationController __viewWillLayoutSubviews] + 57
12  UIKit                               0x01c4bebc -[UILayoutContainerView layoutSubviews] + 213
13  UIKit                               0x019d59c0 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 608
14  libobjc.A.dylib                     0x02f76771 -[NSObject performSelector:withObject:] + 70
15  QuartzCore                          0x00c9827f -[CALayer layoutSublayers] + 152
16  QuartzCore                          0x00c8c105 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 397
17  QuartzCore                          0x00c8bf60 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
18  QuartzCore                          0x00bea676 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 284
19  QuartzCore                          0x00beba3c _ZN2CA11Transaction6commitEv + 392
20  QuartzCore                          0x00cb1789 +[CATransaction flush] + 52
21  UIKit                               0x019487e6 -[UIApplication _reportMainSceneUpdateFinished:] + 39
22  UIKit                               0x01949761 -[UIApplication _runWithMainScene:transitionContext:completion:] + 3163
23  UIKit                               0x01961d30 __84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke + 59
24  UIKit                               0x01947d7f -[UIApplication workspaceDidEndTransaction:] + 155
25  FrontBoardServices                  0x064069de __37-[FBSWorkspace clientEndTransaction:]_block_invoke_2 + 71
26  FrontBoardServices                  0x0640646f __40-[FBSWorkspace _performDelegateCallOut:]_block_invoke + 54
27  FrontBoardServices                  0x06418425 __31-[FBSSerialQueue performAsync:]_block_invoke + 26
28  CoreFoundation                      0x031fa7a0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 16
29  CoreFoundation                      0x031f00b3 __CFRunLoopDoBlocks + 195
30  CoreFoundation                      0x031eff0b __CFRunLoopRun + 2715
31  CoreFoundation                      0x031ef1ab CFRunLoopRunSpecific + 443
32  CoreFoundation                      0x031eefdb CFRunLoopRunInMode + 123
33  UIKit                               0x01947744 -[UIApplication _run] + 571
34  UIKit                               0x0194ae16 UIApplicationMain + 1526
35                                0x000b567d main + 141
36  libdyld.dylib                       0x04dddac9 start + 1
37  ???                                 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

编辑:

- (void)retrieveMessages {
PFQuery *query = [PFQuery queryWithClassName:@"Messages"];
[query whereKey:@"recipientIds" equalTo:[[PFUser currentUser] objectId]];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
    if (error) {
        NSLog (@"Error:%@ %@", error, [error userInfo]);

    }
    else {
        //we found messages
        self.messages = objects;
        [self.tableView reloadData];
        NSLog (@"Retrieved %d messages", [self.messages count]);

    }

    if([self.refreshControl isRefreshing]) {
        [self.refreshControl endRefreshing];
    }
}];
 }



 - (void)viewDidLoad
{
[super viewDidLoad];

self.moviePlayer = [[MPMoviePlayerController alloc] init];

PFUser *currentUser = [PFUser currentUser];
if (currentUser){
    NSLog (@"CurrentUser:%@", currentUser.username);
}
else{

[self performSegueWithIdentifier:@"showLogin" sender:self];

}

self.refreshControl = [[UIRefreshControl alloc] init];
[self.refreshControl addTarget:self action:@selector(retrieveMessages) forControlEvents:UIControlEventValueChanged];
   }


 - (void) viewWillAppear:(BOOL)animated {

[super viewWillAppear:animated];

[self.navigationController.navigationBar setHidden:NO];

[self retrieveMessages];

}

使用 parse.com 作为支持。

在更新之前它工作正常。

请知道如何解决此错误。

感谢您的帮助。

最佳答案

出现此错误似乎是因为您正在执行一个用户必须登录的函数,但在执行该函数时并非如此。 看着other questions ,具体错误似乎与4 0x000ce3cb -[PFQuery whereKey:equalTo:] + 91有关。 查看上面的链接问题,完整的问题陈述很可能是[PFQuery whereKey:equalTo:[PFUser currentUser]]

查看您的代码,以下是问题根源的代码:

[query whereKey:@"recipientIds" equalTo:[[PFUser currentUser] objectId]];

如前所述,如果用户未登录,您需要捕捉并通过添加 return 来阻止函数中的主要代码运行。

链接问题的答案之一:

I just ran into this and it was due to the fact that I was doing an equalTo:[PFUser currentUser] in a PFQuery but there was no logged-in user at that point.

至于当您升级到 iOS 8 SDK(您使用的是 Xcode 6.0.1 和最新的 Parse SDK,对吗?)时为什么会出现这种情况,我不确定;也许它与升级无关,您更改了某些内容导致出现此错误。

关于ios - 更新到 iOS sdk 8.0 后应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26148929/

相关文章:

ios - 防止在点击 UITextField 时出现键盘

ios - 如何获取卡住的 iOS 应用程序的错误报告?

macos - 如何在 iOS 和 OS X 之间创建单一共享框架

ios - 错误 : Error Domain=NSURLErrorDomain Code=-1001 "The request timed out."

ios - 在 swift 编程语言中使用隐式定义的常量类型有什么好处?

ios - 适用于 iOS 的 Google map - 如何判断标记是否在屏幕范围内?

iphone - Reachability startNotifier - 是否需要电话资源

ios - 如何使字典 NSDictionary 对于读取、插入是线程安全的?

uikit - iOS 7 色调颜色 - UINavigationItem 的 backBarButtonItem 在 initWithImage : 时不着色

objective-c - iOS7 Tabbar 图标太大