How to print call stack in Swift?

后端 未结 5 1644
野性不改
野性不改 2020-12-23 11:19

In Objective-C, you can print the call stack by doing the following:

NSLog(@\"%@\", [NSThread callStackSymbols]);

How do you do this in Swi

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-23 12:08

    For Swift 3 use:

    print(Thread.callStackSymbols)
    

    or for better formatting

    for symbol: String in Thread.callStackSymbols {
        print(symbol)
    }
    

提交回复
热议问题