Ahmed Elkhodery
05/21/2023, 1:45 PMprint(__FUNCTION__) // Swift
NSLog(@"%@", NSStringFromSelector(_cmd)); // Objective-C
print(#function)
Jeff Lockhart
05/21/2023, 4:01 PMThrowable().stackTraceToString().lines()
with a regex. The stack trace depth and format varies between platforms, but this should be straightforward if you only need it for iOS. You'll probably need to drop the first couple lines of the stack trace. Then if you know the class name being run in, that helps find the part of the line where the method name starts.Ahmed Elkhodery
05/21/2023, 8:51 PMAdam S
05/24/2023, 5:34 AMJeff Lockhart
05/24/2023, 6:48 PMAdam S
05/24/2023, 6:59 PMJeff Lockhart
05/24/2023, 7:48 PM__MEMBER__
gets the current function name, which sounds like the OP's need. In my case I need the function that called the current function though.Adam S
05/24/2023, 7:51 PMAhmed Elkhodery
05/25/2023, 2:49 AMAhmed Elkhodery
05/25/2023, 2:49 AMJeff Lockhart
05/25/2023, 3:04 PM