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 trialChristopher haro
Courses Plus Student 3,372 PointsHow do add a new collection in the collectionView & register a cell in viewDidLoad with the class? using the word photo?
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".
im guess i start with
registerclass; [ uicollecetionviewcellclass ]
forcellwithreuseidentifier: @"photo"
im not to sure how to finish this one?
Christopher haro
Courses Plus Student 3,372 Pointscapitalization *
{} *
but what about ViewDidLoad: am i way off?
Stone Preston
42,016 Pointslooking at the code you posted in your original post you are heading in the right direction, but pretty far off still. Again since you appear to be struggling with basic syntax and concepts I recommend you do the objective c basics course first. If you keep doing this course and don't really have any idea whats going on you aren't going to learn anything.
Christopher haro
Courses Plus Student 3,372 Pointsok,
3 Answers
Jose Andrade-Sinning
Python Web Development Techdegree Student 12,676 PointsSam,
There seems to be something wrong with this challenge. I'm doing exactly what you are asking and I still can't get through. Here is my code.
#import "SuperCoolViewController.h"
#import "THPhotoCell.h"
@implementation SuperCoolViewController
- (void)viewDidLoad {
[super viewDidLoad];
/* Write your code below this line */
[self.collectionView registerClass:[THPhotoCell class] forCellWithReuseIdentifier:@"Photo"];
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"Photo" forIndexPath:indexPath];
return cell;
}
@end
Amit Bijlani
Treehouse Guest TeacherThe challenge has only one task which is to dequeue new collection view cells in the collectionView. You don't need the cellForItemAtIndexPath
method just the code within the viewDidLoad
method.
Jose Andrade-Sinning
Python Web Development Techdegree Student 12,676 PointsThanks Amit, I was thrown off course by the comment above that suggests using "dequeueReusableCellWithReuseIdentifier:forIndexPath: in cellForItemAtIndexPath:." This is a lot simpler than what it appears. I suggest rewording the challenge instructions or adding some additional comments to clarify.
Sam Soffes
Treehouse Guest TeacherCheckout the UICollectionView reference. You'll need registerClass:forCellWithReuseIdentifier:
in viewDidLoad
and dequeueReusableCellWithReuseIdentifier:forIndexPath:
in cellForItemAtIndexPath:
.
Stone Preston
42,016 PointsStone Preston
42,016 Pointsremember that capitalization matters in objective c, so currently your method calls are incorrect since they dont use camel case. Your also have some invalid syntax in your code.