2017-03-09 9 views
0

私はいくつかの問題を抱えています。エラー - 「タイプの引数リストで 『dataTask』を起動することはできません...」

// Create a datatask and pass in the request 
      let dataTask = session.dataTask(with: request, completionHandler: { (data:NSData?, response:URLResponse?, error:Error?) in 

       // Get a reference to the image view element of the cell 
       let imageView = cell.viewWithTag(1) as! UIImageView 

       // Create an image onject from the data and assign it into the ImageView 
       imageView.image = UIImage(data: data!) 

      }) 

私は、これは誤りである2行目にエラーを取得しています:私はこの問題を解決するにはどうすればよいenter image description here

コード怒鳴るのこのセクションをチェックしてください!前もって感謝します!

+2

'変更してみてください、レスポンス、エラー。 completionHandler):(とメンバーのdataTaskへのあいまいな参照 - 今、私はエラーを取得していますで、{(データ、応答、エラー):リクエスト、completionHandler: – OOPer

+0

は@OOPer [OK]を、ので、ここで更新されたコードだdataTask = session.dataTask(としましょうあなたの代わりにNSURLRequest' 'のURLRequest''助けを – iFunnyVlogger

+1

、あなたの両方!それは働きました! –

答えて

0

によりいくつかのコメントに、私は答えを持っています!データ `に`(エラー:NSDataの?応答:URLResponse ?,エラーデータ?):私は、URLRequestのにNSURLRequestから「要求」に変更し、私はまた、これにコードを更新

// Create a datatask and pass in the request 
      let dataTask = session.dataTask(with: request, completionHandler: { (data, response, error) in 

       // Get a reference to the image view element of the cell 
       let imageView = cell.viewWithTag(1) as! UIImageView 

       // Create an image onject from the data and assign it into the ImageView 
       imageView.image = UIImage(data: data!) 

      }) 
関連する問題