Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Implementing Designs for iPhone Finishing the User Interface Getting Images Using Grand Central Dispatch

Ethan Neff
Ethan Neff
27,058 Points

Ribbit App does not work in iOS 8

Copied the project files with no build errors or warnings. Used my own Parse key, and the app still crashes.

I get this error:

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

There is not a problem with iOS 8. You are attempting to query Parse with the users credentials, but you are not logged in.

Add this peace of code to your -viewDidLoad and it should solve your problem.

if([PFUser currentUser])
{
    [self updateMessages];
}
else
{
    [self performSegueWithIdentifier:@β€œshowLogin” sender:self];
}

All it does is checks if there is a logged in user, if there is, it updates the messages(calls parse for results), otherwise send the user to the log in view.

Ethan Neff
Ethan Neff
27,058 Points

So you're response gave me the motivation to figure out the problem.

*see below

5 Answers

Ethan Neff
Ethan Neff
27,058 Points

The error was happening within the inboxTableViewController.m

For some reason, the viewWillAppear was firing off regardless of what was happening within the viewDidLoad (a segue).

To fix this, change your inboxTableViewController.m

from this:

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    [self.navigationController.navigationBar setHidden:NO];

    [self retrieveMessages];
}

to this:

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    [self.navigationController.navigationBar setHidden:NO];

    if ([PFUser currentUser]) {
        [self retrieveMessages];
    }
}

Im happy to hear you figured it out. One thing to note, it is best to leave the retrieval of messages done in -viewDidLoad and use pull to refresh instead of having to go from one view to another just to refresh. Also, don’t forget the else statement to send the user to login if there is no user logged in.

charlie D
charlie D
5,218 Points

In Xcode 6.1, you made need to manually set your "initial view controller". You can set it from your main storyboard. Select the proper view controller from storyboard, click on your attributes inspector, scroll down until you see check box: "is initial view controller" select it and rerun your program.

Ethan Neff
Ethan Neff
27,058 Points

Unfortunately, that was not the answer to my problem... http://i.imgur.com/RkrX1hs.png

And the answer to this thread did not work for me either.. https://teamtreehouse.com/forum/trying-to-build-the-ribbit-app-in-ios-8-terminating-with-uncaught-exception-nsexception

As of right now, I am using the project files for Ribbit. My Parse key. The latest version of the Parse Framework. The latest version of TPKeyboardAvoiding.

The code worked perfectly before iOS8, and has no warnings or errors, but still crashes whenever launched.

Ethan Neff
Ethan Neff
27,058 Points

The app shows the launch image, but crashes before the login screen.

Lei zheng
Lei zheng
7,990 Points

I have the same problem. when I run the app in any simulator in iOS 7. the app works fine. But if I use simulator running iOS 8.1. Ribbit crash. give out the same error message like yours.

I have what I think is the same problem. My code is as follows:

In viewdidload I have:

PFUser *currentUser = [PFUser currentUser];
    if (currentUser) {
        NSLog(@"Current user: %@", currentUser.username);
    } else {
        [self performSegueWithIdentifier:@"showLogin" sender:self];
    }

What you'd expect is if there is a logged in user, it will NSLog the username and then continue loading the Inbox table view. If not, it triggers the segue "showLogin" which skips the inbox and shows the login/signup view. The problem is, even though the performseguewithidentifier is called and prepareForSegue matches to the "showLogin" segue based on identifier, it never transitions to the loginViewController. Instead the Inbox view continues to load and the viewWillAppear method is called. It crashes in viewWillAppear at:

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

because [PFUser currentUser] returns an empty object and then the query runs and throws an exception.

I think the issue is that its not really correct to transition to another view controller via a segue while in viewDidLoad. I'm curious where a better place to put this logic is?