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 trialSam Chaudry
25,519 PointsStuck on IOS7 Design badge Customizing Table View Controllers badge
cell.accessoryView = [[ UIImageView alloc ] initWithImage:[UIImage imageNamed:@"pizza_slice"]]; Not sure what I'm doing wrong here? Added my code from stage 3/3 and it keeps coming up with an error. Any help would be much appreciated
3 Answers
Ben Jakuben
Treehouse TeacherThat code is working for me. Can you paste in all the code in your Code Challenge editor? Could be a bug in the challenge...
Sam Chaudry
25,519 PointsYeah just pasted it below...
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
cell.accessoryView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"pizza_slice"]];
UIImage *image=[UIImage imageNamed:@"pizza_slice"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
// ... some code omitted for brevity ...
cell.accessoryView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"pizza_slice"]];
return cell;
}
@end
Ben Jakuben
Treehouse TeacherThat code works for me. Are you getting a compiler error? Amit introduced compiler output into the code challenges, but it's a little bit broken with the redesign that was just launched. We're working on improving the experience. If you go back to Task 1 and hit Preview you should be able to see any compiler issues.
You have the line setting cell.accessoryView in there twice...you don't need the one near the top. Also, you can use the imageView variable instead of doing the same code to declare a new UIImageView on the right side of the equals sign. Though combining it like that without the image and imageView variables is a nice, concise way to do it. :)
Sam Chaudry
25,519 PointsSam Chaudry
25,519 PointsSeems to have worked now, still got an error message through from the console, so I think maybe your right could have just been a bug. Any how thanks for for looking it to it Ben
Ben Jakuben
Treehouse TeacherBen Jakuben
Treehouse TeacherDoh - now I see this comment. :) Glad it's working!