Skip to content

Instantly share code, notes, and snippets.

@YuiChiLo
Last active October 2, 2016 00:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YuiChiLo/03ce2917e94b81868fb5934811fd341a to your computer and use it in GitHub Desktop.
Save YuiChiLo/03ce2917e94b81868fb5934811fd341a to your computer and use it in GitHub Desktop.
Playground上で端末ロケールを変更する
// MARK: - 端末のロケール設定
extension NSLocale {
class func customLocale() -> NSLocale {
return NSLocale(localeIdentifier: "ja")
}
}
let methodLocale = class_getClassMethod(NSLocale.self, #selector(getter: NSLocale.current))
let swizzledMethodLocale = class_getClassMethod(NSLocale.self, #selector(NSLocale.customLocale))
method_exchangeImplementations(methodLocale, swizzledMethodLocale)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment