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 trialKeegan Gladstone
Courses Plus Student 16,208 Pointsset 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
9,372 PointsBecause 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;
Keegan Gladstone
Courses Plus Student 16,208 Pointsawesome thank you!
Gareth Borcherds
9,372 PointsDon't forget to mark best answer :)
Gareth Borcherds
9,372 PointsGareth Borcherds
9,372 PointsAlso, 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.