0

Given the following, Is it possible to use some sort of reflective mechanism in Swift/Obj-C to get the string "foo" from the reference bar?

I've looked at this and some other SO posts, but they seem to be focused on apply reflection to classes, not lone functions. I saw method_getName, but I don't know how to translate a Swift function to a Method object.

func foo(p1:Any, p2:String) -> Int {
    return -1
}
func getName(fn:Any) -> String {
    return // name of fn
}
print(getName(fn))
Community
  • 1
  • 1
Julian A.
  • 10,928
  • 16
  • 67
  • 107

0 Answers0