自学Swift-斯坦福笔记整理(十七) Internationalization and Settings
来源:互联网 发布:java常用对象及api 编辑:程序博客网 时间:2024/05/03 14:58
Internationalization
Internationalization(i18n)
localization(l10n)
func NSLocalizedString(
key: String,//这是唯一方式去验证字符.通常想哟啊放到屏幕上的开发者语言
tableName: String,bundle: NSBundle,
value: String//它将使用如m果它不能找到这个一个翻译者并不能翻译这些key
comment: String //这个将高速翻译者,这些是内容
) -> String
大部分情况 tableName和bundle都是默认的,这个tableName需要本地化bundle将作为你主要的bundle(你的app)
String.localizedStringWithFormat(
NSLocalizedString(“the result is %g”,comment:”give numeric result to the user”),theNumber
)
formatters是基于本地的
一个是语言,另一个是位置
NSNumberFormatter()
NSDateFormatter
NSDateComponentsFormatter
NSByteCountFormatter
MKDistanceFormatter
NSNumberFormatter Demo
let formatter = NSNumberFormatter()
var nsmberStyle: NSNumberFormatterStyle //.DecimalStyle,.CurrencyStyle
let stringToDisplay = formatter.stringFromNumber(theNumber)
Settings
所有设置设置用户界面是通过NSUserDefaults
设置Settings Bundle
NSUserDefaults.standardUserDefaults().doubleForKey(“")
//通知,因为如果在设置里进行了设置用户不重启APP的话设置是没用的
NSNotificationCenter.defaultCenter().addObserverForNamr(NSUserDefaultsDidChangeNotification,nil,nil){}//闭包里在放设置SettingBundle的值
0 0
- 自学Swift-斯坦福笔记整理(十七) Internationalization and Settings
- 自学Swift-斯坦福笔记整理(十四) Core Location and MapKit
- 自学Swift-斯坦福笔记整理(五)
- 自学Swift-斯坦福笔记整理(六)
- 自学Swift-斯坦福笔记整理(七)
- 自学Swift-斯坦福笔记整理(八)
- 自学Swift-斯坦福笔记整理(十三) Application Lifecycle and Core Motion
- 自学Swift-斯坦福笔记整理(十六) Camera, Persistence, and Embed Segues
- 自学Swift-斯坦福笔记整理(第四天开始)
- 自学Swift-斯坦福笔记整理(十) TextFile table view Smashtag
- 自学Swift-斯坦福笔记整理(十一) Unwind segue alert
- 自学Swift-斯坦福笔记整理(十二) Physics based Dynamic Animation
- 自学Swift-斯坦福笔记整理(十五) Modal Segues
- 自学Swift-斯坦福笔记整理(九) -- 滚动视图 闭包 多线程
- 自学 Swift整理
- Swift自学笔记(1)
- Swift学习笔记(十七)协议
- Internationalization and Localization
- 自学Swift-斯坦福笔记整理(十五) Modal Segues
- 几种进程间的通信方式
- LeetCode3:Longest Substring Without Repeating Characters
- dojo小例子(36)ResizableDialog widget可缩放对话框
- 自学Swift-斯坦福笔记整理(十六) Camera, Persistence, and Embed Segues
- 自学Swift-斯坦福笔记整理(十七) Internationalization and Settings
- 大量 D3.js 示例
- abs,绝对值
- 软件测试的学习心得
- 记一道关于链表的面试题
- POJ 1050 DP
- Quarts 官方简单示例1
- POJ - 2299 Ultra-QuickSort(树状数组)
- Linux下配置jdk1.7