2016-08-21 3 views

답변

1
static func isKeyboardInstalled() -> Bool { 
     var isInstalled = false 

     if let dict: AnyObject = NSUserDefaults.standardUserDefaults().dictionaryRepresentation() { 
      let userDefaultsDictionary: Dictionary<String, AnyObject> = dict as! Dictionary<String, AnyObject> 
      let keyboardArrayAnyObject: AnyObject? = userDefaultsDictionary["AppleKeyboards"] 
      if let array: AnyObject = keyboardArrayAnyObject { 
       let keyboardsArray: Array<String> = array as! Array<String> 
       let appUrlSceme: String? = SystemUtils.applicationIdentifier() 

       if let urlScheme = appUrlSceme { 
        for item in keyboardsArray { 
         if (item as NSString).containsString(urlScheme) { 
          isInstalled = true 
         } 
        } 
       } 
      } 
     } 

     return isInstalled 
    } 

    static func applicationIdentifier() -> String? { 
     var appIdentifier: String? = nil 

     if let identifier = NSBundle.mainBundle().objectForInfoDictionaryKey(kCFBundleIdentifierKey as String) as? String { 
      appIdentifier = identifier 
     } 

     return appIdentifier 
    }