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 trialKal K
13,332 PointsRecipients aren't showing up in Ribbit project
hey guys i need help on my Ribbit project, the recipients screen is not showing up after clicking on the picture
12 Answers
Alexander Teague
9,501 PointsTry downloading the completed project files and compare them to your code?
Andrew Kelly
4,738 PointsHi Kalson,
Can you post your code?
Kal K
13,332 Points#import "CameraViewController.h"
#import <MobileCoreServices/UTCoreTypes.h>
@interface CameraViewController ()
@end
@implementation CameraViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.friendsRelation = [[PFUser currentUser] relationForKey:@"friendsRelation"];
}
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
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;
NSLog(@"%@", self.friends);
[self.tableView reloadData];
}
}];
self.imagePicker = [[UIImagePickerController alloc]init];
self.imagePicker.delegate = self;
self.imagePicker.allowsEditing = NO;
self.imagePicker.videoMaximumDuration = 10;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
self.imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
else {
self.imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
self.imagePicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:self.imagePicker.sourceType];
[self presentViewController:self.imagePicker animated:NO completion:nil];
}
#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;
}
#pragma mark - Table view delegate
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{}
#pragma mark - Image Picker Controller Delegate
- (void) imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[self dismissViewControllerAnimated:NO completion:nil];
[self.tabBarController setSelectedIndex:0];
}
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
// A photo was taken/selected
self.image = [info objectForKey:UIImagePickerControllerOriginalImage];
if (self.imagePicker.sourceType == UIImagePickerControllerSourceTypeCamera) {
// Now we can save the image!
UIImageWriteToSavedPhotosAlbum(self.image, nil, nil, nil);
}
}
else {
// A video was taken/selected
NSURL *imagePickerURL = [info objectForKey:UIImagePickerControllerMediaURL];
self.videoFilePath = [imagePickerURL path];
if (self.imagePicker.sourceType == UIImagePickerControllerSourceTypeCamera) {
// Now we can save the video!
if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(self.videoFilePath)){
UISaveVideoAtPathToSavedPhotosAlbum(self.videoFilePath, nil, nil, nil);
}
}
}
}
@end
Andrew Kelly
4,738 PointsHi Kalson,
It looks like your header information is missing. That's the first thing I'd look into. Have you included the following?
@property (nonatomic, strong) PFRelation *friendsRelation;
Kal K
13,332 PointsYeah I have it in my header too. There are no errors, but for some reason I can't get into the recipient screen like Ben Jakuben did. I think i missing something in the code.
My header file:
#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
@interface CameraViewController : UITableViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate>
@property (nonatomic, strong) UIImagePickerController *imagePicker;
@property (nonatomic, strong) UIImage *image;
@property (nonatomic, strong) NSString *videoFilePath;
@property (nonatomic, strong) NSArray *friends;
@property (nonatomic, strong) PFRelation *friendsRelation;
@end
Andrew Kelly
4,738 PointsHi Kalson,
When you view your friends, does the list show up properly under both Friends and Edit Friends? Just wanting to make sure there's no other issues.
Kal K
13,332 Pointsyes they show up properly
Andrew Kelly
4,738 PointsOK. I am just trying to read through your code (its hard without the formatting) but I noticed that it was maybe missing an import. Are you calling?
#import <MobileCoreServices/UTCoreTypes.h>
Kal K
13,332 PointsYeah i have it imported also
Andrew Kelly
4,738 PointsHave you gone into your Main Storyboard and linked the table cell to an identifier?
I also see that you're logging the users. Do they show up in the log?
Kal K
13,332 Pointsyeah I linked the cell identifier and the users are showing up in the console. (the current user and the relation friends )
Kal K
13,332 Pointsyeah I linked the cell identifier and the users are showing up in the console. (the current user and the relation friends )
Andrew Kelly
4,738 PointsCan you share a link with the project files on dropbox or github? I will take a look and maybe there's something I am missing.
Kal K
13,332 PointsAndrew Kelly
4,738 PointsTry this Kalson. Instead of this line of code in the viewDidLoad method:
self.friendsRelation = [[PFUser currentUser] relationForKey:@"friendsRelation"];
Delete that line and in the viewWillAppear under [viewWillAppear] put in the following:
self.friendsRelation = [[PFUser currentUser] objectForKey:@"friendsRelation"];
Let me know if that works out OK for you.
Kal K
13,332 PointsYea I tried it earlier and just tried it again, but its still not working
Andrew Kelly
4,738 PointsWould it be possible to get the whole project uploaded to git hub? That way I can run the code inside of your storyboard and structure. It might help me see what's going on.
Kal K
13,332 PointsI figure it out thanks man! :3 I forgot to write the dismissal code
Ben Jakuben
Treehouse TeacherEverything looks good! Assuming you have the correct cell identifier ("Cell") in your storyboard, can you debug or log anything from cellForRowAtIndexPath
to see how it's trying to adapt the data?
Kal K
13,332 PointsYes i have the correct identifier ("Cell") in the storyboard for the prototype cell of the camera view controller. can i send you the file?
Kal K
13,332 PointsI figure it out thanks man! :3 I forgot to write the dismissal code
Ben Jakuben
Treehouse TeacherCool - glad you got it working! :)
Alexander Teague
9,501 PointsCheck you haven't named your cell identifier Cell instead of cell etc that was my problem when i and the same issue. The case has to be identical, and i see you have put Cell as your identifier not cell
Kal K
13,332 PointsYes i have the correct identifier ("Cell") in the storyboard for the prototype cell of the camera view controller.
Kal K
13,332 PointsKal K
13,332 Points:3 Thanks! looking at that, i realized that I forgot to write the dismissal code. I thought i had check for it too, but i guess i didn't check well. thanks again!