iphone - ICU 在 iOS 上的 MessageFormat

标签 iphone ios icu

据我了解,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/

相关文章:

c++ - 在 Windows VC++ 2010 静态链接下构建 boost + ICU

c - ICU 转换与 ucnv_toUnicode

iphone - UIActivityViewController 有错误的按钮标题颜色

iphone - 从自定义 UIControl 子类转发事件

ios - 无法在 Swift 中调用特定的 Objective-C 类方法

ios - 使隐藏/取消隐藏主视图 Controller 在横向上的工作与纵向相同

c++ - ICU 自定义货币格式 (C++)

iphone - 在 Interface Builder 中创建的 UITableViewCell segue 不会触发

iphone - 在缩放的 MKMapView 上合并注释

ios - 在 iOS 应用程序及其扩展之间共享 Storyboard