//JSONString轉(zhuǎn)字典
? ? funcgetDictFromString(jString:String) ->NSDictionary{
? ? ? ? letjsonData:Data= jString.data(using: .utf8)!
? ? ? ? letdict =try? JSONSerialization.jsonObject(with: jsonData, options: .mutableContainers)
? ? ? ? ifdict !=nil{
? ? ? ? ? ? returndictas!NSDictionary
? ? ? ? }
????????????returnNSDictionary()
? ? }
? ? //版本更新
? ? funchsUpdateApp() {
? ? ? ? letappId:String="**********"
? ? ? ? //獲取appstore上的最新版本號
? ? ? ? letappUrl = URL.init(string:"http://itunes.apple.com/lookup?id="+ appId)
? ? ? ? guardletappMsg =try? String.init(contentsOf: appUrl!, encoding: .utf8)else{
? ? ? ? ? ? return
? ? ? ? }
? ? ? ? letappMsgDict:NSDictionary= getDictFromString(jString: appMsg)
? ? ? ? letappResultsArray:NSArray= (appMsgDict["results"]as?NSArray)!
? ? ? ? letappResultsDict:NSDictionary= appResultsArray.lastObjectas!NSDictionary
? ? ? ? letappStoreVersion:String= appResultsDict["version"]as!String
? ? ? ? letfhappStoreVersion = appStoreVersion .replacingOccurrences(of:".", with:"")
? ? ? ? letappStoreVersion_Float:Float= Float(fhappStoreVersion)!
? ? ? ? //獲取當(dāng)前手機(jī)安裝使用的版本號
? ? ? ? letlocalVersion:String= Bundle.main.infoDictionary!["CFBundleShortVersionString"]as!String
? ? ? ? letfhlocalVersion = localVersion .replacingOccurrences(of:".", with:"")
? ? ? ? letlocalVersion_Float:Float= Float(fhlocalVersion)!
? ? ? ? //appstore上的版本號大于本地版本號 - 說明有更新
? ? ? ? ifappStoreVersion_Float > localVersion_Float {
? ? ? ? ? ? ? ? ? ? /*
彈框確認(rèn)按鈕事件
????????????????letupdateUrl:URL= URL.init(string:"http://itunes.apple.com/app/id"+ appId)!
? ? ? ? ? ? ? ? ?UIApplication.shared.open(updateUrl, options: [:], completionHandler:nil)
????????????????????*/
?? ? ? ?}
? ? }