'Cannot do a comparison query for type: (null)

2019-06-25 11:38发布

问题:

My app is crashing in the app delegate.

The error it's throwing is:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Cannot do a comparison query for type: (null)'

My code is below. I've left the logging statements in so you can see where I've been checking things:

self.viewController = [[ParseStarterProjectViewController alloc] initWithNibName:@"ParseStarterProjectViewController" bundle:nil];
NSLog(@"View controller is %@",self.viewController);
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
NSLog(@"Nav controller is %@",navController);
NSLog(@"Self window is %@",self.window);
self.window.rootViewController = navController;

It's breaking when it tries to run that last line, setting the rootViewController to the navController.

The results from the 3 NSLog lines are as follows:

View controller is <ParseStarterProjectViewController: 0x1fda0770>
Nav controller is <UINavigationController: 0x1fda1390>
Self window is <UIWindow: 0x1fd97c90; frame = (0 0; 320 480); opaque = NO; autoresize = RM+BM; layer = <UIWindowLayer: 0x1fd97d90>>

It doesn't look like anything is null to me, which is why I'm extremely confused.

回答1:

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.



回答2:

This really wound up being a question about "how do I get more information out of a crash log". rmaddy's comment pointed me in the right direciton.

Sean's answer here sorted me out.