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 Simple iPhone App (iOS7) Testing and Debugging Debugging Basics

Jacob McLaws
Jacob McLaws
1,497 Points

What are breakpoints used for?

I just watched the video on breakpoints and debugging. At the end Amit talks about how you can set breakpoints on specific lines of code. Is that so that you can isolate where things might be broken? I'm a little confused as to use cases when I'd want to just run bits of my code at a time.

1 Answer

Breakpoints stop execution at a particular area in your code. For example, say you have a 300 line project. You notice your output isn't what you expected. You could set a breakpoint at every 25th line following each run, and try to spot where the error occurs. They're just a way of keeping you from pulling your hair out, or swearing at your computer... Maybe.

Here's a good blog post on breakpoints: http://jeffreysambells.com/2014/01/14/using-breakpoints-in-xcode