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 trialTamara J
189 PointsTrying to Build the Ribbit app in iOS 8: Terminating with Uncaught Exception : NSException
Hi everyone, trying to build the Ribbit app with the new iOS, but it keeps failing at login. Here's the code.
(IBAction)login:(id)sender {
NSString *username = [self.enterUsername.text stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *password = [self.enterPassword.text stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if ([username length] == 0 || [password length] == 0) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Oops!"
message:@"Please enter a username, password."
delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
return;
}else {
[PFUser logInWithUsernameInBackground:username password:password block:^(PFUser *user,
NSError
*error) {
if (error) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sorry!"
message:[error.userInfo
objectForKey:@"error"]
delegate:nil cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
else {
[self.navigationController popToRootViewControllerAnimated:YES];
}
}];
}
}
The error message:
2014-10-21 11:40:17.047 Yes-No App[5401:605012] *** Terminating app due to uncaught
exception 'NSInvalidArgumentException', reason: 'Cannot do a comparison query for
type: (null)'
Anyone know how to tweak it so it works for iOS 8
Edit:
I see others were having issues with it before...not sure how I can fix this as it's the same code from the application.
Second Edit: I have all the code...used your example Russell and it still threw an exception...breakpoint was different though.
Tamara J
189 PointsHi Russell,
I actually had the code for when the login was successful, I just didn't copy and paste all of it. My mistake!
I used the code example you provided and it still failed, the Breakpoint was this: 0x148ca5: jmp 0x148cb8 ; +[PFInternalUtils assertValidClassForQuery:] + 394 at PFInternalUtils.m:413
Russell Warwick
1,601 PointsFair enough works for me fine haha. Programing is frustrating... Also try disabling breakpoints ?
Tamara J
189 PointsHow do I do that?
Russell Warwick
1,601 PointsGo to debug and then click on deactivate breakpoints. Sometimes it will still not work but most of the time it will unstick where your code is stuck on :)
Erion Vlada
13,496 PointsSaw someone else with the same issue, so ill just parse the fix below. Hope it helps.
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.
TIP: Copy and paste the error code on google if you can decipher it, it will most likely have happened to someone else before.
2 Answers
Tamara J
189 PointsYeah, someone on StackOverflow helped me fix it:
''' if ([userName length] ==0 || [Password length]==0) {
UIAlertView * alertView =[[UIAlertView alloc]initWithTitle:@"Oops!" message:@"Please enter a username and password" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alertView show];
} else {
[PFUser logInWithUsernameInBackground:userName password:Password block:^(PFUser *user, NSError *error) {
if (user) {
[self.navigationController popToRootViewControllerAnimated:YES];
}
}];
} }
'''
Ethan Neff
27,058 PointsAny solution to this problem? My Ribbit stopped working with the same error in iOS 8 as well.
Tamara J
189 PointsSee my answer above.
Ethan Neff
27,058 PointsUnfortunately, that solution did not work for me...
I am still unable to run the app even after implementing your code... http://i.imgur.com/fcw01ix.png
Tamara J
189 PointsHey Ethan,
Are you running it with iPhone 6? The thing that solved my problem was running it in a different project (copying and pasting the code in a new one). I don't know what I did exactly, but I did try running it in the iPhone 5 simulator, and I think that helped a little. I'm not sure.
I hope this proves helpful to you.
Ethan Neff
27,058 PointsTamara, is there anyway you could send me a copy of your project?
I just cannot get my Ribbit to work like it did before iOS 8.
Ethan Neff
27,058 PointsFigured out the solution to my problem... it can be found here: https://teamtreehouse.com/forum/ribbit-app-does-not-work-in-ios-8
Russell Warwick
1,601 PointsRussell Warwick
1,601 PointsYou have missed out what happens if the login is successful ?
show look like this <-(IBAction)logIn:(id)sender{ NSString *userName = [self.userNameField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; NSString *password = [self.passwordField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if ([userName length] ==0 || [password length]==0) {
} else {
} }