Skip to content

Instantly share code, notes, and snippets.

View YuiChiLo's full-sized avatar

Yuichiro YuiChiLo

View GitHub Profile
@YuiChiLo
YuiChiLo / NSLocale+Playgournd.swift
Last active October 2, 2016 00:55
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)
import UIKit
extension UIViewController {
func getForegroundAlertController() -> UIAlertController? {
var viewController = UIApplication.sharedApplication().keyWindow?.rootViewController
while let controller = viewController?.presentedViewController {
if controller is UIAlertController {
viewController = controller
import UIKit
/// Syntax Swift 2.2
extension UIAlertController {
class func showIndicatorAlert(viewController: UIViewController, message: String) {
let alert: UIAlertController = self.init(title: nil, message: message, preferredStyle: .Alert)