Cocoa: Break on every method call?

前端 未结 3 922
花落未央
花落未央 2021-01-13 07:13

Often when debugging, it\'s important for me to know what methods of a class are being called in what order. The naive solution (that I\'ve been using thus far) is to pop an

3条回答
  •  心在旅途
    2021-01-13 08:05

    All Objective-C method calls go through one of the C runtime calls objc_msgSend, objc_msgSend_stret, objc_msgSendSuper and objc_msgSendSuper_stret per the 'Sending Messages' section of the Objective-C Runtime Reference. So you should be able to trap those, and give them actions to log the relevant parts of the first two parameters (it's target and selector for the normal sends, a struct describing the superclass that contains both the target and the class type for super calls).

提交回复
热议问题