I need to get the current filename in Swift programatically.
Is it possible? Is there any hack that can be used to do the same?
Yes, you can simply use #file
macro to get the name of the current file.
You can
Eg. just try compiling the following file Swift 3:
println(#file)
Swift 2 or older:
println(__FILE__)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With