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!
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

Brian Law
4,099 PointsApp crashes, Xcode highlights line with "Thread 1: breakpoint 1.1"
The app crashes without fully loading and I'm not sure why. It doesn't return any specific error, but it does highlight a line from func collectionView
(for me, the function is line 106 in ViewController.swift and the highlighted line is 112. return cell
)
This is my code from the function. It's mostly code that came in the download, I think.
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath) as? VendingItemCell else { fatalError() }
let item = vendingMachine.selection[indexPath.row]
cell.iconView.image = item.icon()
return cell
}

Brian Law
4,099 PointsThanks for the help! I had set a breakpoint by accident, and had also removed it by accident. Gave me a chance to learn a bit more about breakpoints so not entirely a useless mistake.
2 Answers

Jason Anders
Treehouse Moderator 145,840 PointsHey Brian,
Without actually seeing the whole situation, I can't be 100%, but from the message you posted that Xcode returned, it doesn't look like the app crashed. But rather, it looks like the app stopped at a set breakpoint. Whether you set this break point on purpose or accidentally, I don't know. As for it working now, you may have removed the breakpoint while trying to debug (again either on purpose or accidentally.)

Caleb Kleveter
Treehouse Moderator 37,862 PointsYou will need to remove the breakpoint so you code doesn't pause.
In the gutter on the left side of your code, there will be a fat blue arrow on the line that the code stopped on. Right-click the arrow an select 'Remove breakpoint.' This should solve you problem.
Brian Law
4,099 PointsBrian Law
4,099 PointsI'm going to leave this open in case someone else finds out what might have gone wrong because it might be helpful to others, but it started working. I don't think I made any changes, though I might have accidentally changed something when I was looking at what was going wrong.