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

No visible @interface for 'NSString'

Hi, i'm having the error of no visible @interface for 'NSString' declares the selector 'stringByTrimmingCharacterInSet:' for the 3 lines of NSString code and the use of undeclared identifier 'otherButtonTitles'. How to solve?

  • (IBAction)signup:(id)sender {

    NSString *username = [self.usernameField.text stringByTrimmingCharacterInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

    NSString *password = [self.passwordField.text stringByTrimmingCharacterInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

    NSString *email = [self.emailField.text stringByTrimmingCharacterInSet:[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:(NSString *) otherButtonTitles:nil];

    [alertView show];

    }

}

http://teamtreehouse.com/library/ios-development/build-a-selfdestructing-message-app/using-parsecom-as-a-backend-and-adding-users/signing-up-new-users-part-1-uialertview

2 Answers

It looks like you have a method spelled wrong which is why you are getting the first error. I’d take another look at the video, or the documentation to see what the proper method name is.

As for the second error you’re getting, that is because you didn’t pass the right information to the initWithTitle method. Take a look at what you have the cancelButtonTitle set as.

Ok, i corrected the second one but the first one i still don't know why. The usernameField, passwordField and emailField does not turn green like in the video. Any idea?

You have:

stringByTrimmingCharacterInSet

Which should be:

stringByTrimmingCharactersInSet

Hi Patrick, i manage to run the code but the app is terminated by Xcode. It shows this: Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<LoginViewController 0x7c6a150> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key login.'

Just an update, i manage to figure out how to solve it. The problem is due to connecting more than one referencing outlets on the storyboard. I deleted the connection in the m file but the old connection is till on the storyboard. I disconnected the old one on the storyboard and it's working fine now. So guys, remember to press control and click on the text field and button to check the connection. Thanks Patrick!

I'm working in Xcode 5 GM Seed Release and kept having this problem, until I read this post. It now works if I delete the outlet connections and re-add them.

Thanks!