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 Build a Self-Destructing Message iPhone App Using Parse.com as a Backend and Adding Users Signing Up New Users: Part 2 (PFUser)

App Crashing During Signing Up New Users Part 2 - PFUser Lesson

Just completed the lesson in the subject line which goes over how to setup new sign-ups in parse.

I completed the video and followed along with the tutorial. My code shows no bugs and successfully launches.

When I fill out the sign up for and hit submit, the app crashes.

Here's the error:

2014-06-04 00:04:11.485 Ribbit[925:60b] -[NSCFCharacterSet length]: unrecognized selector sent to instance 0x10a711840 2014-06-04 00:04:11.490 Ribbit[925:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFCharacterSet length]: unrecognized selector sent to instance 0x10a711840' *** First throw call stack: ( 0 CoreFoundation 0x0000000102828495 exceptionPreprocess + 165 1 libobjc.A.dylib 0x000000010258799e objc_exception_throw + 43 2 CoreFoundation 0x00000001028b965d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205 3 CoreFoundation 0x0000000102819d8d ___forwarding_ + 973 4 CoreFoundation 0x0000000102819938 CF_forwarding_prep_0 + 120 5 Foundation 0x000000010214c6e2 -[NSString stringByAppendingString:] + 130 6 Ribbit 0x0000000100002797 -[SignupViewController signup:] + 327 7 UIKit 0x0000000101135f06 -[UIApplication sendAction:to:from:forEvent:] + 80 8 UIKit 0x0000000101135eb4 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 17 9 UIKit 0x0000000101212880 -[UIControl _sendActionsForEvents:withEvent:] + 203 10 UIKit 0x0000000101211dc0 -[UIControl touchesEnded:withEvent:] + 530 11 UIKit 0x000000010116cd05 -[UIWindow _sendTouchesForEvent:] + 701 12 UIKit 0x000000010116d6e4 -[UIWindow sendEvent:] + 925 13 UIKit 0x000000010114529a -[UIApplication sendEvent:] + 211 14 UIKit 0x0000000101132aed _UIApplicationHandleEventQueue + 9579 15 CoreFoundation 0x00000001027b7d21 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION_ + 17 16 CoreFoundation 0x00000001027b75f2 __CFRunLoopDoSources0 + 242 17 CoreFoundation 0x00000001027d346f __CFRunLoopRun + 767 18 CoreFoundation 0x00000001027d2d83 CFRunLoopRunSpecific + 467 19 GraphicsServices 0x0000000103981f04 GSEventRunModal + 161 20 UIKit 0x0000000101134e33 UIApplicationMain + 1010 21 Ribbit 0x00000001000024b3 main + 115 22 libdyld.dylib 0x00000001031095fd start + 1 23 ??? 0x0000000000000001 0x0 + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException

And here's my code starting at the IBAction:

- (IBAction)signup:(id)sender {

NSString *username = [self.usernameField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *password = [self.passwordField.text stringByAppendingString:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *email = [self.emailField.text stringByAppendingString:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

if ([username length] == 0 || [password length] == 0 || [email length] == 0) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Oops" message:@"Make sure you enter a username, password, and email address!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];

[alertView show];

}

else {
PFUser *newUser = [PFUser user];

newUser.username = username;
newUser.password = password;
newUser.email = email;

[newUser signUpInBackgroundWithBlock:^(BOOL succeeded, 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];
}
 }];
}
}

@end

Thanks for your time,

Ryan

3 Answers

Started the entire project over from scratch and now it works! I noticed when creating properties for the user/pass/email fields in signupViewController.h, I listed them as strong instead of weak. Not sure if this caused the issue. All fixed now.

Romain Gaget
Romain Gaget
24,449 Points

Hi Ryan

Have a look at your AppDelegate.m and check if you entered the right applicationId and clientKey (information that you'll pick up from your parse settings. (see below)

[Parse setApplicationId:@"xxxxxxxxxxxxxx" clientKey:@"xxxxxxxxxxxxxxx"];

Thomas Nilsen
Thomas Nilsen
14,957 Points

Also check that your IBAction is actually hooked up to the button in your storyboard