据我了解,iOS 在后台使用 ICU。我想访问 ICU 的 MessageFormat 功能,以处理涉及数字和复数的字符串,例如,
There {0,choice,0#are no files|1#is one file|1<are {0,number,integer} files}.
iOS 是否公开此功能?如果是这样,我该如何使用它?我以为我可以写
[NSString stringWithFormat: "There {0,choice,0#are no files|1#is one file|1<are {0,number,integer} files}.", n];
或
[NSString stringWithFormat: "There {0,plural, =0{are no files}=1{is one file}other{are %ld files}}.", n];
但是这些格式(分别是 ICU4J 和 ICU)不起作用。
最佳答案
iOS 和 OS X 一样,包含 /usr/lib/libicucore.dylib
。但是,它在任何一个操作系统上都不是受支持的公共(public) API。参见 this old message了解如何在 OS X 上使用它,以及有哪些潜在问题。
在 iOS 上,我想还有一个问题是 Apple 可能会拒绝您使用不受支持的 API 的应用程序。
关于iphone - ICU 在 iOS 上的 MessageFormat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10367735/