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
John Nguyen
2,682 PointsExtra Credit ProfileViewController
Hi guys , I'm struggling with the query of this extra credit. Any suggestions
PFQuery *query = [PFUser query];
[query whereKey:@"username" equalTo:self.userId];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (error) {
NSLog(@"Error: %@ %@", error, [error userInfo]);
} else {
self.users = objects;
PFUser *foundUser = [self.users objectAtIndex:0];//I'm pretty sure this isn't how I should do it, I set PFUser to the query but it gives //me an error .
self.userNameLabel.text = foundUser.username;
NSLog(@"Works");
}
}];
I'm trying to pull my data from parse. And then display the data into my text labels.
John Nguyen
2,682 PointsI'm trying to pull data from the selected user(from my table) via query and then set the data equal to my labels. But I'm struggling and I don't know how.
John Nguyen
2,682 PointsAll of it is declared under my viewDidLoad on the ProfileViewController.m
-
(void)viewDidLoad { [super viewDidLoad];
PFQuery *query = [PFUser query];
[query whereKey:@"username" equalTo:self.userId];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { if (error) {
NSLog(@"Error: %@ %@", error, [error userInfo]); } else { self.users = objects; PFUser *foundUser = [self.users objectAtIndex:0]; self.userNameLabel.text = foundUser.username; NSLog(@"Works"); }
}];
}
John Nguyen
2,682 PointsOkay I fixed it a bit , but now my labels are returning null. This is all under viewDidLoad
PFUser *selectedUser = [PFQuery getUserObjectWithId:self.userId];
NSLog(@"username: %@" , selectedUser.username);
self.userNameLabel.text = selectedUser.username;
self.emailLabel.text = selectedUser.email;
1 Answer
John Nguyen
2,682 PointsI'm trying to pull data from the selected user(from my table) via query and then set the data equal to my labels. But I'm struggling and I don't know how.
Stone Preston
42,016 PointsStone Preston
42,016 Pointswhat exactly are you trying to accomplish