Does anyone know if any Apple Open Source repository would contain the source code to NSStringFromSelector
? TSAN has pointed out an issue in my code that stems from assuming that the value returned by NSStringFromSelector
is immutable, and that the function itself is re-entrant. I’d like to check both those assumptions against the actual sources... assuming they haven't changed in macOS Sequoia to begin with.
AFAIK NSStringFromSelector
isn’t open source but it’s not a very complicated routine. What heavy lifting is being done is done by sel_getName
, which is in the Darwin open source. Beyond that, the logic looks like this:
-
If
sel
isnil
returnnil
. -
If
sel_getName
returnsNULL
, returnnil
. -
Otherwise create a string for the C string using
-initWithBytesNoCopy:length:encoding:freeWhenDone:
.
Ah, and the NSStringFromSelector
code hasn’t changed in macOS 15 beta, although it’s possible that sel_getName
might’ve.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"