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 trialDavid Lin
35,864 PointsUnnecessary call to performSegueWithIdentifier
In the CollectionViewController, the "showDetail" segue is already hooked up to show modally in the storyboard, so the call to performSegueWithIdentifier in didSelectItemAtIndexPath is redundant. By having this unnecessary call, prepareForSegue is needlessly called twice.
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
// UNNECESSARY CALL, WHICH CAUSES prepareForSegue TO BE NEEDLESSLY CALLED TWICE
[self performSegueWithIdentifier:@"showDetail" sender:self];
}
NOTE: In the next video, the existing segue is deleted and replaced by one connecting the collection view controller to the detailed view controller to get rid of a warning/error in the console. Then the above call becomes necessary to actually perform the segue when the user selects an item.