IT English Collection(2)of Formatter(IOS)

1 前言

今天我们介绍一篇关于IOS的格式化官方解释文档。

2 详述

2.1 正文

A formatter is an object that automatically converts a string representation of a value to an object representing that value, and vice versa. For example, an NSNumberFormatter object can convert the string “1.25” to an NSNumber object representing the value 1.25. An NSDateFormatter; objects can convert an NSDate object representing December 12, 2009 to “11/22/2009”. As you can see, the conversion works both ways, from string to value object and value object to string. The abstract base class for formatters is NSFormatter. You may subclass NSFormatter to create formatters for other types of data, even custom data types defined by your application’s data model.


Configuring and Applying a Formatter
When you create a date or number formatter object, you can configure it in many ways, but the primary attributes are formatter style and locale. You can give NSNumberFormatter objects a decimal, currency, percent, scientific, or “spell-out” style (for example, “25” to “twenty-five”). You can give NSDateFormatter objects both date and time styles in a range of explicitness, for example, from “11/22/2009” to “Sunday, November 22, 2009 AD”.

You may also apply an NSLocale object to a formatter object so that it reflects a certain locale; for example, “1.02” in U.S. English would be “1,02” in French. To get the current locale (set by the user), call the NSLocale class method currentLocale.

After you have configured a date or number formatter, you apply it to a string obtained from the user interface (typically a text field) to obtain the value object; or you apply it to an NSDate or NSNumber object and write the resulting string to an object in the user interface. The methods you call for these purposes are dateFromString:, stringFromDate:, numberFromString:, and stringFromNumber:.

2.2 生词汇总

vice [vaɪs]prep. 代替

versa ['vɜ:sə]adj. 反的

explicitness [iks'plisitnis]n. 直言不讳;明确性
reflect [rɪ'flekt]vt. 反映;反射
certain ['sɜːt(ə)n; -tɪn]adj. 某一;必然的;
locale [ləʊ'kɑːl]n. 场所,现场
obtain [əb'teɪn]vt. 获得
purpose ['pɜːpəs]n. 目的;用途

3 结语

以上是所有内容,希望对大家有所帮助。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值