Andrew Tuzson
Andrew Tuzson

Reputation: 639

Understanding breakpoints and threads in swift

I am trying to wrap my head around debugging and threads in Swift/Xcode. I have added a breakpoint to the beginning of a method and in the callstack, I see several references to different methods. The first method is used to create the UIImageView, the second is to add that UIImage to the view, and the third is to handle the tap gesture. When the user taps the screen, the final method is call, thus calling the first two methods. Is this why I see each of these in the callstack? What are the dotted lines below the third method in the callstack? Please see the photo below:

enter image description here

Upvotes: 2

Views: 548

Answers (1)

Alex
Alex

Reputation: 3981

Your description of what is happening is correct, the breakpoint you set includes a call stack of how you got to the breakpoint. In this case, the main thread was listening for touch events, and when it got one it fired the handleSingleTap: method which then called another method, which called another method that had a line of code with a breakpoint in it. The dashed line is not that important to understand, it delineates the point where your app's code starts being run, instead of the underlying Foundation code, it is only there to make the call stack easier to read. You may be confused in that the call stack goes bottom to top, the lower methods are put on top of the stack, so they originate at the bottom from main and go up to the method that has your breakpoint in it.

Upvotes: 2

Related Questions