Debugging breakpoints as a replacement for prints – onlinecode
In this post we will give you information about Debugging breakpoints as a replacement for prints – onlinecode. Hear we will give you detail about Debugging breakpoints as a replacement for prints – onlinecodeAnd how to use it also give you demo for it if it is necessary.
Debugging breakpoints in Xcode allows you to replace prints and reuse debugging statements in future debugging sessions. By simply enabling and disabling needed breakpoints you can also get rid of debug levels as often defined in libraries like CocoaLumberjack.
- Reuse breakpoints by enabling them when needed
- Use breakpoints to replace print statements
- Keep your code clean without debugging logs
Inspired by @twostraws’s debugging presentation at @AppdevconNL I now keep around breakpoints instead of print statements for debugging.
✅ Enable / Disable when needed
? Catch bugs faster with reusing debug breakpointsExample: JSON printing in the console ?? pic.twitter.com/JB0lLyyRll
— Antoine v.d. Lee (@twannl) July 12, 2018
Using debugging breakpoints
The most simple implementation of debugging breakpoints is by adding a print breakpoint instead of adding a print statement in our code. Instead of the following code:
print("Did add (content.count) content items to bucket (bucket.name)")
We create a breakpoint on the line where we want the print to be triggered. By right-clicking the breakpoint and selecting Edit breakpoint...
we enter the breakpoint detail view.
The breakpoint menu
In this view, you are able to define the behaviour of the breakpoint once it’s triggered.
Editing a breakpoint
This will log the following line in your console:
"Did add 2 content items to bucket Photos"
po
stands for print object and can be used to print any reachable objects within the context of the breakpoint line. By ticking Automatically continue after evaluating actions
you allow the debugger to continue without pausing once the breakpoint is hit.
You can do a lot more with debugging breakpoints. A great start is to check out the talk by Paul Hudson “How to debug like a pro” which is available here.
Hope this code and post will helped you for implement Debugging breakpoints as a replacement for prints – onlinecode. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs