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
Swift 4
Here's my approach:
func pretty_function(_ file: String = #file, function: String = #function, line: Int = #line) {
let fileString: NSString = NSString(string: file)
if Thread.isMainThread {
print("file:\(fileString.lastPathComponent) function:\(function) line:\(line) [M]")
} else {
print("file:\(fileString.lastPathComponent) function:\(function) line:\(line) [T]")
}
}
Make this a global function and just call
pretty_function()
Bonus: You will see the thread is executed on, [T] for a background thread and [M] for the Main thread.