A format specifier such as `%15@` works in NSLog but not with NSString stringWithFormat

别等时光非礼了梦想. 提交于 2019-12-04 10:13:34
matt

The mystery is why %15@ would ever work. It should not.

Format specifiers come from sprintf which has no %@ (it is just a special extension for Objective-C). As far as stringWithFormat goes, %15s has always been the way to say this; I can cite Stack Overflow examples such as NSString stringwithformat: Padding 2 strings with unknown length.

I'm guessing it only "works" because it now uses os_log under the hood; unfortunately, the os_log syntax is almost completely undocumented.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!