hash/pound(#)在格式字符串中表示什么?

nev*_*ing 4 string formatting objective-c

我有一些代码来格式化文件大小字符串:

NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; 
[numberFormatter setPositiveFormat: @"#,##0.## bytes"];
Run Code Online (Sandbox Code Playgroud)

是否与@"#,##0.## bytes"我在stringWithFormat中使用的格式字符串相同?哈希/磅符号在这里意味着什么?

sam*_*son 8

#通常会被一个数字替换(如果存在的话),如果没有,则没有.如果存在一个数字,则0将被替换;如果不存在,则将其替换为零.

因此,对于以下格式化'## 00.00 ##',您将获得以下输出:

1 => 01.00
12.1 => 12.10
1234.5 => 1234.50
1.2345 => 01.2345
Run Code Online (Sandbox Code Playgroud)