Is there a Swift alternative for NSLog(@“%s”, __PRETTY_FUNCTION__)

前端 未结 11 1158
梦谈多话
梦谈多话 2020-12-02 07:39

In Objective C you can log the method that is being called using:

NSLog(@\"%s\", __PRETTY_FUNCTION__)

Usually this is used from a logging m

11条回答
  •  天涯浪人
    2020-12-02 08:16

    I use, this is all that is required in a swift file, all other files will pick it up (as a global function). When you want to release the application just comment out the line.

    import UIKit
    
    func logFunctionName(file:NSString = __FILE__, fnc:String = __FUNCTION__){  
        println("\(file.lastPathComponent):\(fnc)")
    }
    

提交回复
热议问题