Sorry if this is a duplicate, but I tried to search, including Apple String Format Specifiers and IEEE printf spec , but could not find an answer for something so simple.
I would like to print an os_log message with string formatting for a string constant. Something similar to:
printf("Currently at processing state: %s\n", "reading in");
in C. However, when I tried something like this in Swift:
os_log("Currently at processing state: %s", log: .default, type: .info, "reading in")
he just didn't print anything.
How to print a string constant using a string format specifier? I am not sure how to do this using NSLog .
Edit: os_log requires StaticString , so it cannot do something like "Something \(Expr) Something else" , as in print() . You can use string formatting to print numeric variables. I am wondering how to print string constants / variables in this case.
Edit 2: Apple really discusses this topic on its page, which I managed to skip because it was discussed only in the Objective-C API version.
source share