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)

set username and password challenge

Hey All,

I'm having a bit of trouble with my code challenge. I am supposed to set the 2 properties in the signup method (username and password) to the 2 UITextFields (usernameField and passwordField). With my code below, I get the error: "Make sure you set both the 'username' and 'password' properties!".... Any suggestions? Thanks!

#import "SignupViewController.h"
#import <Parse/Parse.h>

@implementation SignupViewController

- (IBAction)signup:(id)sender {
NSString *username = [self.usernameField text];
NSString *password = [self.passwordField text];

}
@end

2 Answers

Gareth Borcherds
Gareth Borcherds
9,372 Points

Because username and password are already properties, you would need to set them using the self. notation as below.

#import "SignupViewController.h"
#import <Parse/Parse.h>

@implementation SignupViewController

- (IBAction)signup:(id)sender {
    self.username = self.usernameField.text;
    self.password = self.passwordField.text;
}

@end

That is because we probably already set them up as a NSString in the header file using something like

@property (nonatomic, strong) NSString *username;
@property (nonatomic, strong) NSString *username;
Gareth Borcherds
Gareth Borcherds
9,372 Points

Also, I used self.usernameField.text in my answer, but that is the equivalent of what you put [self.usernameField text]

Both of them work fine once you start using the self. instead of declaring a new NSString.

awesome thank you!

Gareth Borcherds
Gareth Borcherds
9,372 Points

Don't forget to mark best answer :)