Print Class Name of Current File in Swift

前端 未结 6 1609
[愿得一人]
[愿得一人] 2020-12-30 03:36

I\'m trying to print the name of the current class in Swift. More specifically, I\'d like achieve the following output:

myFunction() in ClassContainingTheFun         


        
6条回答
  •  甜味超标
    2020-12-30 04:00

    I think the following is what you want (in Swift 2.1 and up):

    print("\(__FUNCTION__) in \(self.dynamicType)")
    

提交回复
热议问题