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 trialTrent Burkenpas
22,388 PointsCan not connect storyboard to my custom class
Trying to connect custom class "FriendsViewController" to my storyboard. But, the class is not showing up with all the other custom classes. (if that makes any sense).
Thanks !
22 Answers
Stone Preston
42,016 PointsTry typing in the name of your class. You don't have to choose it in the drop down, you can type it in if it's not showing up. Sometimes closing the storyboard and reopening it or cleaning your project will fix it if it's not appearing, but I usually just type it in
derekalia
3,974 PointsI have the same problem! The friends list is empty but the console is showing that the code is retrieving a friends list, there are users in the list. Maybe something isn't hooked up right. Any suggestions?
derekalia
3,974 PointsSolved!
Trent Burkenpas
22,388 PointsYeah I tried that, but the problem was that my friends were not showing up on my friends list in the ribbit app. So I figured that my "Friends" Table View was connected properly to my custom class. Maybe there is a error in my code. I think i'm going to just redo that part. Thanks for the help!
Ben Jakuben
Treehouse TeacherIf you're still stuck, paste in your view controller code and we'll help you get sorted out. :)
Trent Burkenpas
22,388 PointsWell out of pure frustration, i copy and paste all the code form the project file, and now i'm getting this error message
2014-01-28 17:34:00.579 Ribbit[8333:1303] Error: Error Domain=com.parse.networking.error Code=-1011 "Expected status code in (200-299), got 401" UserInfo=0x99d88d0 {NSErrorFailingURLKey=https://api.parse.com/2/user_login, NSLocalizedDescription=Expected status code in (200-299), got 401} (Code: 100, Version: 1.2.18)
it might be a issue with my storyboard ??
Thank you!
Trent Burkenpas
22,388 PointsOk well this is funny! I decided to restart this project and i'm stuck on the same issue! Friends will not show up on the friends page.
Ben Jakuben here is my code for the FriendsViewController!
FriendsViewController.h
#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
@interface FriendsViewController : UITableViewController
@property (nonatomic, strong) PFRelation *friendsRelation;
@property (nonatomic, strong) NSArray *friends;
@end
FriendsViewController.m
#import "FriendsViewController.h"
@interface FriendsViewController ()
@end
@implementation FriendsViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.friendsRelation = [[PFUser currentUser] objectForKey:@"friendsRelation"];
PFQuery *query = [self.friendsRelation query];
[query orderByAscending:@"username"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (error) {
NSLog(@"Error %@ %@", error, [error userInfo]);
}
else {
self.friends = objects;
[self.tableView reloadData];
}
}];
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [self.friends count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
PFUser *user = [self.friends objectAtIndex:indexPath.row];
cell.textLabel.text = user.username;
return cell;
}
@end
Thank you so much!
Stone Preston
42,016 Pointsput an NSLog after your query is successful to log the users in your array. something like
else { self.friends = objects; [self.tableView reloadData]; NSLog(@"users in friends array: %@", self.friends; }
if the array is empty, somethings going on with your relation/query
if the array has data in it, something is going on with your table view delegate methods
Trent Burkenpas
22,388 PointsHey Preston,
I tried what you suggested, but nothing showed up in the console. So could it be a issue with the friendsRelation queries?
Stone Preston
42,016 Pointsnothing at all? did you use this statement?
NSLog(@"users in friends array: %@", self.friends);
it should have at least printed something? make sure you select to show the console by clicking the icon on on the right side of the trash can in the debug view, I would click both the the icons so you show the console and the variables view.
Trent Burkenpas
22,388 PointsHey Preston,
I tried what you suggested, but nothing showed up in the console. So could it be a issue with the friendsRelation queries?
Trent Burkenpas
22,388 PointsYeah thats all open,
because i do see this "2014-02-06 16:50:44.790 Ribbit[10547:70b] Current user: Trent"
maybe i typed in something wrong??
- (void)viewDidLoad
{
[super viewDidLoad];
self.friendsRelation = [[PFUser currentUser] objectForKey:@"friendsRelation"];
PFQuery *query = [self.friendsRelation query];
[query orderByAscending:@"username"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (error) {
NSLog(@"Error %@ %@", error, [error userInfo]);
}
else {
self.friends = objects;
[self.tableView reloadData];
NSLog(@"users in friends array: %@",self.friends);
}
}];
}
Stone Preston
42,016 Pointsok implement viewWillAppear and move all your friendsRelation code and query into that method instead of viewDidLoad
Trent Burkenpas
22,388 Pointsok, nothing happened. did i do it correctly?
- (void)viewDidLoad
{
[super viewDidLoad];
}
-(void)viewWillAppear:(BOOL)animated {
self.friendsRelation = [[PFUser currentUser] objectForKey:@"friendsRelation"];
PFQuery *query = [self.friendsRelation query];
[query orderByAscending:@"username"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (error) {
NSLog(@"Error %@ %@", error, [error userInfo]);
}
else {
self.friends = objects;
[self.tableView reloadData];
NSLog(@"users in friends array: %@",self.friends);
}
}];
}
Stone Preston
42,016 Pointsyou forgot to call [super viewWillAppear:animated];
Trent Burkenpas
22,388 Pointsok I corrected my code, and I still do not see any changes
Stone Preston
42,016 Pointshmm ok add an NSLog at the top of viewWillAppear something like NSLog(@"viewWillAppearCalled"); so we can see if that method is being called
Trent Burkenpas
22,388 PointsOk, "viewDidAppearCalled" did show up in the console!
Stone Preston
42,016 Pointsok now we are getting somewhere. It looks like you query isnt running. can you double check in the parse data browser if your PFUser class does indeed have a relation named friendsRelation associated with it?
Trent Burkenpas
22,388 PointsIt does have a relation named friendsRelation
Stone Preston
42,016 Pointscan you click the relation for whatever user you log in as and view the friends in the data browser?
Stone Preston
42,016 Pointsinteresting. place a log inside your query block but before the if/else block like so to see if the query is indeed running:
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
NSLog(@"query ran");
if (error) {
NSLog(@"Error %@ %@", error, [error userInfo]);
}
else {
self.friends = objects;
[self.tableView reloadData];
NSLog(@"users in friends array: %@",self.friends);
}
}];
Trent Burkenpas
22,388 Pointsok, the NSLog did appear !
Stone Preston
42,016 Pointsok so the query is running. try using this code (which basically is the opposite of what you currently have, just kind of switches the if/else around
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if(!error){
self.friends = objects;
[self.tableView reloadData];
NSLog(@"friends: %@", self.friends);
} else {
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
}];
Trent Burkenpas
22,388 PointsHmmm that didn't change anything....debugging is the worst!
Stone Preston
42,016 Pointsman I really dont know whats going on. in your if/else print a log that says either @"error occurred" or @"success" depending on which block its in. that will tell you if your if/else blocks are being run.
Trent Burkenpas
22,388 PointsOk, I tried that and I didn't get any of the logs in the console. Im think that the if/else isn't being run
Stone Preston
42,016 Pointsi really dont understand why. If anything that else should be running if there is an error. I really dont know what to tell you. Makes no sense
Trent Burkenpas
22,388 PointsWell Thank you for all the help. I think I just need to step away from this and come back to it later lol
Trent Burkenpas
22,388 PointsBen Jakuben Your my only hope lol
Ben Jakuben
Treehouse TeacherWhoa - sorry you're having all this trouble! I'm just now catching up on support in the Forum again after releasing my latest Android course. At this point, can you zip up your project and email it to help@teamtreehouse.com? If I can find anything I'll reply back in here.
Trent Burkenpas
22,388 PointsWow you do both ios and Android? Which one do you prefer? lol Anyway thank you for the help, ill send it in as soon as I get a chance!
Ben Jakuben
Treehouse TeacherI love both but prefer Android! The concepts are very similar between the two, so it really comes down to getting comfortable with the language and APIs. Definitely check out the Android projects some time!
Trent Burkenpas
22,388 Pointscool I plan on learning both, just started with ios because i have a mac lol