已更新至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作为备用。
在更新之前它工作正常。
请知道如何解决此错误。
感谢您的帮助。
答案 0 :(得分:2)
这个错误似乎正在发生,因为您正在执行一个用户必须登录的功能,但不是在执行该功能时。
查看other questions,具体错误似乎与4 0x000ce3cb -[PFQuery whereKey:equalTo:] + 91
有关。
查看上面的链接问题,完整的问题陈述可能是[PFQuery whereKey:equalTo:[PFUser currentUser]]
。
查看代码,以下是代码问题的根源:
[query whereKey:@"recipientIds" equalTo:[[PFUser currentUser] objectId]];
如前所述,如果用户未登录,您将需要捕获并通过添加return
阻止功能中的主代码运行。
相关问题的答案之一:
我刚碰到这个,这是因为我在PFQuery中做了一个相同的事情:[PFUser currentUser],但那时没有登录用户。
至于为什么在升级到iOS 8 SDK时开始出现这种情况(你使用的是Xcode 6.0.1和最新的Parse SDK,对吧?),我不确定;也许它与升级无关,你改变了一些东西来发生这个错误。