문제

How can I log every message sent in a single iteration of the Objective-C event loop?

I want to further my understanding of the Objective-C runtime and thought this would be a good start.

도움이 되었습니까?

해결책

These functions will cause all messages to be logged to a file in /tmp, based on the PID of the process. Good on simulator, but not on an iDevice.

// Start logging all messages
instrumentObjcMessageSends(YES);

// Stop logging all messages
instrumentObjcMessageSends(NO);

다른 팁

The CFRunLoopObserver opaque type should do exactly what you want. It is

a general means to receive callbacks at different points within a running run loop.

Use the activity argument to its creation function to specify when you want your observer serviced. For your case, this will probably be either kCFRunLoopEntry or kCFRunLoopExit.

You can get the CFRunLoopRef from the current NSRunLoop, [[NSRunLoop currentRunLoop] getCFRunLoop], or by using CFRunLoopGetCurrent().

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top