Time for action – Using breakpoints

  1. Position the carat on the line that you want to pause execution on and use the hotkey combination Apple- to create the breakpoint. For many keyboard-centric developers this is the preferred way of doing things.

    Time for action – Using breakpoints

    The other method is to click on the spine area to the left of the code and line numbers. If you are more a mouse-centric developer, you will find this to be the more natural way for setting breakpoints.

    Time for action – Using breakpoints
  2. Observe that the line that you created the breakpoint on is highlighted with a red circle in the spine next to the code. This represents an active breakpoint.

    To deactivate a breakpoint, simply click on the red circle or press Apple- again and the breakpoint will be removed.

    It should be noted that if you create a breakpoint on a line that contains no actual code, the break point would actually execute on the next line of executable code.

  3. Run the application.
    Time for action – Using breakpoints

We can now observe that the application stops on the line where the breakpoint was located. This gives us an opportunity to observe the state of the application at the time when the breakpoint is reached. Many times it is useful to put a breakpoint inside of some control structure, such as an if statement, to see if the conditions which should trigger it are ever met.

What just happened?

You have just created a breakpoint within your application and had your app stop on the line specified. When the application is in this state it is paused so that you can examine and/or change the state of any variables of the application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.242.118