您如何将堆栈跟踪打印到 Cocoa 中的控制台/日志? [英] How do you print out a stack trace to the console/log in Cocoa?

查看:20
本文介绍了您如何将堆栈跟踪打印到 Cocoa 中的控制台/日志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在某些时刻记录调用跟踪,例如失败的断言或未捕获的异常.

解决方案

此代码适用于任何线程:

NSLog(@"%@", NSThread.callStackSymbols);

<块引用>

返回一个包含调用堆栈符号的数组.每个元素都是一个 NSString 对象,其值的格式由 backtrace_symbols() 函数确定.

I'd like to log the call trace during certain points, like failed assertions, or uncaught exceptions.

解决方案

This code works on any thread:

NSLog(@"%@", NSThread.callStackSymbols);

Returns an array containing the call stack symbols. Each element is an NSString object with a value in a format determined by the backtrace_symbols() function.

这篇关于您如何将堆栈跟踪打印到 Cocoa 中的控制台/日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆