Boon
Boon

Reputation: 41500

How to trace out all messages sent to a particular class or instance in Objective-C?

I would like to trace out all messages sent by the Objective-C runtime to a particular class, say UITableView (or a particular instance) so I can better understand the inner workings of some classes. Is there a way to do this?

Another use case is to trace out all delegate methods that are being called (say UITableViewDelegate methods) without having to declare them and put a trace method in each of them.

Upvotes: 2

Views: 211

Answers (1)

kperryua
kperryua

Reputation: 10534

This may be a little heavy-handed, but try setting the NSObjCMessageLoggingEnabled environment variable to YES. That will show all the messages sent to every object, but you can easily filter it down to the messages sent to a particular class.

Some good tips here: http://www.dribin.org/dave/blog/archives/2006/04/22/tracing_objc/

Disclaimer: I'm not sure if the environment variable works for iPhone.

Upvotes: 2

Related Questions