     class func storyboard(name: String) -> UIStoryboard {
         
         //there is no localized universal storyboard
-        if let storyboardURL = NSBundle.mainBundle().URLForResource(name, withExtension: "storyboardc") {
-            if NSFileManager.defaultManager().fileExistsAtPath(storyboardURL.path!) {//there is no localized universal storyboard
+        if let storyboardURL = Bundle.main.url(forResource: name, withExtension: "storyboardc") {
+            if FileManager.default.fileExists(atPath: storyboardURL.path) {//there is no localized universal storyboard
                 return UIStoryboard(name: name)
             }
             //there is no universal storyboard
-            if UIDevice.isIpad() {//there is no localized ipad storyboard
+            if UIDevice().userInterfaceIdiom == .pad {//there is no localized ipad storyboard
                 let iPadStoryboardName = name + "_iPad"//Specified by the naming rule, to separate resources
                 return UIStoryboard(name: iPadStoryboardName)
             }

import UIKit.UIStoryboard

private var kMainStoryboardName: String {
    let info = NSBundle.mainBundle().infoDictionary
    
    if let value = info?["UIMainStoryboardFile"] as? String {
        return value
    }
    else {
        return "Main"//default name for main storyboard
    }
}

extension UIStoryboard {
    
    class var mainStoryboard: UIStoryboard {
        struct Static {
            static let instance: UIStoryboard = UIStoryboard(name: kMainStoryboardName)
        }

    }
    
    convenience init(name: String) {
        self.init(name: name, bundle: Bundle.main)
    }
}
