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 Build a Photo Browser iPhone App Collection Views Implementing a Custom UICollectionViewCell

Caleb Kleveter
MOD
Caleb Kleveter
Treehouse Moderator 37,862 Points

I'm not really understanding this.

I'm supposed to "We want to dequeue new collection view cells in the collectionView property of this class. Before we can do that, register a cell in viewDidLoad with the class THPhotoCell. Use the identifier "Photo"." I saw Soffes use dequeue but I'm not sure how I would use it in this challenge. I tried

dequeueReuseableCellWithReuseIdentifier:@"Photo" forIndexPath:indexPath;

But I got an error that said "Bummer! There is a compiler error. Please click on preview to view your syntax errors!"

I checked the preview and there was nothing their.

5 Answers

Iulian Popescu
Iulian Popescu
1,363 Points

Since it's a method it should have a ")" at the end of row, but you haven't.

Iulian Popescu
Iulian Popescu
1,363 Points

Since it's a method it should have a ")" at the end of row, but you haven't.

Caleb Kleveter
MOD
Caleb Kleveter
Treehouse Moderator 37,862 Points

That didn't work.

#import "SuperCoolViewController.h"

@implementation SuperCoolViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    /* Write your code below this line */
    (dequeueReuseableCellWithReuseIdentifier:@"Photo" forIndexPath:indexPath);

}

@end
Iulian Popescu
Iulian Popescu
1,363 Points

First of all sorry that I answer so late, but I was quite busy last days and I can't see your post. In case that it isn't solved yet here is what I think that you should do:

  • you are writing obj-c code so, any method is called with "[ ]", not "( )" (It was my bad because I thought that your code was in swift)

  • "dequeReuseableCell...." is a UITableView method so it have to be called by an instance of this class (something like that --> [myTableView dequeReuseableCell....] )

  • the method from above shouldn't be in viewDidLoad, but in cellForRowAtIndexPath

  • I think that in your viewDidLoad you wanted to register a cell for your tableview. If so, check this to do it properly.

If it's still not working, post again and I will answer much faster.

Caleb Kleveter
MOD
Caleb Kleveter
Treehouse Moderator 37,862 Points

Thanks for the reply, I've got the same reason for the delay :). What's happening is I'm working on a code challenge. The instructions are as follows:

"We want to dequeue new collection view cells in the collectionView property of this class. Before we can do that, register a cell in viewDidLoad with the class THPhotoCell. Use the identifier "Photo"."

Here is the code I start with.

#import "SuperCoolViewController.h"

@implementation SuperCoolViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    /* Write your code below this line */

}

@end