2016-12-07 6 views
0

私はerrorAlamofireこの

func checkfornewVersionofApp() { 

    let appId = NSBundle.mainBundle().infoDictionary!["CFBundleIdentifier"] 
    let appIdString = appId as! String 

    let theitunesUrl = "http://itunes.apple.com/en/lookup?bundleId=" + appIdString   

    Alamofire.request(.GET, theitunesUrl, parameters: nil).responseJSON { response in  
     switch response.result { 
      case .Success(let JSON): 
       print("success with json : \(JSON)") 
       break 
      case .Failure(let error): 
       print("some error occured : \(error.localizedDescription)") 
       break 
     } 
    } 
} 

それは常に行くの下に使用しては、AppStoreからの私のappversionを取得しようとしている上にエラーを与え、

次の操作を完了できませんでし提供します。 JSONをシリアル化できませんでした。 入力データはゼロまたは長さゼロでした

理由は何ですかhope yur help。

+1

'responseJSON'の代わりに' responseData'を使用してください。 –

+0

レスポンスを使用してください.result.value、 –

答えて

4

URLに問題があります。このリンクをチェックし、あなたのコードに加えて

let theitunesUrl = "http://itunes.apple.com/lookup?bundleId=" + appIdString

let theitunesUrl = "http://itunes.apple.com/en/lookup?bundleId=" + appIdString

を変更

Link for iTunes API

、あなたが特定の国のために結果を得るために、クエリに国のパラメータを追加することができますApp Store。例えば

http://itunes.apple.com/lookup?bundleId=com.yelp.yelpiphone&country=de

説明、ユーザーの評価と他のフィールドは異なるApp Storeの国の間で変更される可能性があります。

+1

thanx mate、あなたは素晴らしい仕事をしました – bill