Apple爸爸的OC调试工具

iOS自带调试工具,还可强大,给张gif体验一下

UIDebuggingInformationOverlay.gif

代码如下:

UIViewController+Debugging.h

#import 

@interface UIViewController (Debugging)
- (void)showDebugger;
@end

UIViewController+Debugging.m

#import "UIViewController+Debugging.h"

@implementation UIViewController (Debugging)
- (void)showDebugger
{
#ifdef DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
    id debugClass = NSClassFromString(@"UIDebuggingInformationOverlay");
    [debugClass performSelector:NSSelectorFromString(@"prepareDebuggingOverlay")];
    
    id debugOverlayInstance = [debugClass performSelector:NSSelectorFromString(@"overlay")];
    [debugOverlayInstance performSelector:NSSelectorFromString(@"toggleVisibility")];
#pragma clang diagnostic pop
#endif
}
@end

PS:转Ryan Peterson,侵立删

你可能感兴趣的:(Apple爸爸的OC调试工具)