【发布时间】:2016-09-26 12:32:07
【问题描述】:
我刚刚更新了我的 Xcode,并一直在尝试了解更多有关它的信息。这是我的 Collection View Cell 代码。我正在尝试从 URL 获取数据,但我一直对这个错误感到恼火。我在这里尝试了所有解决方案,但它们具有不同的功能结构。其他解决方案也不起作用。
import UIKit
class PersonCell: UICollectionViewCell {
@IBOutlet weak var personImage : UIImageView!
func ConfigureCell (imgURL : String)
{
}
func DownloadImage ( url : NSURL)
{
}
func GetDatafromURL (URL : NSURL , completion : @escaping (( _ data : NSData? , _ response : URLResponse? , _ error : NSError?) -> Void))
{
URLSession.shared.dataTask(with: URL) { (data , response , error) in
completion (data , response, error)
}.resume()
}
}
教程视频中的代码是这样的
func GetDatafromURL (URL : NSURL , completion : (( data : NSData? , response : NSURLResponse? , error : NSError?) -> Void))
{
NSURLSession.sharedSession.dataTaskWithURL( URL) { (data , response , error) in
completion(data : data , responce : response, error : error)
}.resume()
【问题讨论】: