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

Szabolcs Varga
PLUS
Szabolcs Varga
Courses Plus Student 662 Points

Parse.com: How to retrieve multiple users profile image

I have an array called allMyContacts, it stores PFUser objects (the friends of the current user). I could already list them in a table view, but i can't retrieve their profile images and load into the table view cells. I'm storing the profile images in the pre-defined user class as a PFFile. When i run the app it crashes with this error: -[UIImageView setFile:]: unrecognized selector sent to instance . So it's sure that something is wrong with the PFFile *file, but i can not figure it out. Could somebody explain me what did i wrong? Thanks.

-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    FriendsCell *cell = [self.tableViewTwo dequeueReusableCellWithIdentifier:@"friendsDevCell"];
    PFUser *user = [self.allMyContact objectAtIndex:indexPath.row];

    PFFile *file = [user objectForKey:@"imageFile"];

    cell.profilImageView.file = file;

    [cell.profilIView loadInBackground];

    cell.mySimpleContactUsernameLabel.text = user.username;

    return cell;
  }

2 Answers

Caleb Abraham
Caleb Abraham
15,158 Points

Unless you have a custom file parameter in you profilIView, I don't believe you can call cell.profileImageView.file directly. You may want to try this:

```cell.profilImageView.image = [UIImage imageNamed:file];

Szabolcs Varga
Szabolcs Varga
Courses Plus Student 662 Points

I get this warning for this: "Incompatible pointer types sending 'PFFile *' to parameter of type 'NSString *'" . I'm sure that the .file is correct, i use it elsewhere. I think the table view is the problem.

Szabolcs Varga
PLUS
Szabolcs Varga
Courses Plus Student 662 Points

I get this warning for this: "Incompatible pointer types sending 'PFFile *' to parameter of type 'NSString *'" . I'm sure that the .file is correct, i use it elsewhere. I think the table view is the problem.