Create a gist now

Instantly share code, notes, and snippets.

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