我向https://itunes.apple.com/lookup?id=APPID
提出请求时遇到了一个非常奇怪的问题如果我在浏览器中尝试此网址,则会显示该应用的当前版本。但如果我从iOS应用程序调用它,它会给我旧的。
这是我使用的代码
let stringUrl : String = "https://itunes.apple.com/lookup?id=APPID"
let req : NSMutableURLRequest = NSMutableURLRequest(url: URL(string: stringUrl)!, cachePolicy: NSURLRequest.CachePolicy.reloadIgnoringCacheData, timeoutInterval: 10.0)
req.httpMethod = "get"
let manager = AFHTTPRequestOperationManager()
manager.responseSerializer = AFJSONResponseSerializer()
let r = manager.httpRequestOperation(with: req as URLRequest!,
success: { (operation: AFHTTPRequestOperation?,responseObject: Any?) in
if let responseDic :Dictionary<String, AnyObject> = responseObject as? Dictionary<String, AnyObject> {
let currentVersion: String = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String
let results = responseDic.first?.value as! Array<AnyObject>
let dic = results.first as! Dictionary<String,AnyObject>
let version : String = dic["version"] as! String
//let version : String = responseDic.object(forKey: "results")?[0].object(forKey: "version") as! String
self.isUpToDate = currentVersion == version
delegate.onVersionReceived(version)
}
},
failure: { (operation: AFHTTPRequestOperation?,error: Error?) in
})
r.start()
关于发生了什么事的想法?
答案 0 :(得分:-1)