在Objective-C中,我们可以使用__LINE__和__PRETTY_FUNCTION__宏。这些都不会以Swift语言暴露出来。是否有另一种方式在Swift中获取类似的信息?
Swift Language Reference defines提供这种行为的几个“特殊文字”:
原文链接:https://www.f2er.com/swift/320488.htmlLiteral Type Value __FILE__ String The name of the file in which it appears. __LINE__ Int The line number on which it appears. __COLUMN__ Int The column number in which it begins. __FUNCTION__ String The name of the declaration in which it appears.