4 ms·
This is Foundation API, not Swift stdlib. One thing Swift probably can do, is to have the first parameter typed as StaticString. I am not sure if the header for
by liuliu 5y ago
This is Foundation API, not Swift stdlib. One thing Swift probably can do, is to have the first parameter typed as StaticString. I am not sure if the header for NSLog has enough annotations to do so.
OTOH: https://github.com/apple/swift-log https://github.com/apple/swift-log
- tialaramex 5y agoYes, format strings should be required to be static strings. Logging frameworks, printf, i18n frameworks, anything that has arbitrary format strings they need to be literals or you're going to shoot yourself in the foot. I'm surprised here that the author ends up believing that, on the one hand, this function behaves as if it has variadic parameters (hence the format specifiers), but then on the other hand they have no option but to somehow write all their text as the first parameter. These are logically inconsistent beliefs, but maybe too much fighting with Apple's ecosystem causes you to just stop believing the world has to make sense.