Objective C / iPhone:如何提取当前区域的实际 unicode 日期格式字符串?
根据该网站: http://iosdevelopertips.com/cocoa/date-formatter-examples.html
有一个处理格式化的类,它接受一组常量/枚举(例如 NSDateFormatterShortStyle)到“setDateStyle”属性/方法。
NSDateFormatter 知道以某种方式检索正确的特定于区域设置的日期格式。我想要的是能够根据用户选择的区域格式检索默认格式。我有一种感觉它存储在 NSLocale 中,但这似乎没有公开任何可以检索格式字符串的内容。
有没有办法提取格式?它必须在内存中的某个地方;我希望检索机制暴露在某个地方。
我已经查看了几个地方,但我得到的唯一答案是关于如何从自定义格式创建 NSDate 的课程。
According to this site:
http://iosdevelopertips.com/cocoa/date-formatter-examples.html
there is a class that handles formatting, which takes in a set of constants/enums (e.g. NSDateFormatterShortStyle) to the "setDateStyle" property/method.
Somehow the NSDateFormatter knows to retrieve the proper locale-specific date format. What I want is to be able to retrieve the default formats based on the user's choice of region format. I have a feeling it is stored in NSLocale, but that does not seem to expose anything that will retrieve the format strings.
Is there a way to extract the formats? It has to be in memory somewhere; I'm hoping the retrieval mechanism is exposed somewhere.
I've looked in several places, but the only answers I get are a lesson on how to create an NSDate from a custom format.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
刚刚在 OS X 上进行了测试,但这应该也适用于 iOS。
Just tested on OS X but this should also work in iOS.