2015-04-12 57 views
1

我不知道這是用戶錯誤還是由於Xcode和Swift更新。我拉着圖像文件從解析,並不管我怎麼調整的語法,我得到了一個持久的錯誤:無法解析的錯誤與解析「獲取數據的背景塊」

迅速:64:23:無法調用「getDataInBackgroundWithBlock」與類型的 參數列表「( (?!NSData的NSError) - >無效)

我的代碼是:

func callData() { 

    var imageQuery = PFObject(className: "QuestionMaster") 
    let iconImageFile = imageQuery["questionImage"] as! PFFile! 
    iconImageFile.getDataInBackgroundWithBlock { 
     (imageData: NSData!, error: NSError?) -> Void in 

     if (error == nil) { 

      self.icon1 = UIImage(data: imageData[0]) 
      self.icon2 = UIImage(data: imageData[1]) 
      self.icon3 = UIImage(data: imageData[2]) 
      self.icon4 = UIImage(data: imageData[3]) 
      self.icon5 = UIImage(data: imageData[4]) 
      self.icon6 = UIImage(data: imageData[5]) 
      self.icon7 = UIImage(data: imageData[6]) 
      self.icon8 = UIImage(data: imageData[7]) 
      self.icon9 = UIImage(data: imageData[8]) 
     } 
     else { 
      NSLog("Something went wrong.") 
     } 

我已經從剖析文檔直工作。我也曾嘗試:

iconImageFile.getDataInBackgroundWithBlock(imageQuery, block: { 
      (imageData: NSData!, error: NSError?) -> Void in 

而且我交換!?無濟於事。在我的代碼findObjectInBackgroundWithBlock的其他地方也會發生同樣的情況。

回答

2

這是由於swift 1.2中的變化所致。解析應該已經提供了一個解決這個問題的框架版本。從他們的網站下載它。

編輯

另外,不要忘記解開與if let

下面的代碼爲imageData值使用SWIFT 1.2

imageFile.getDataInBackgroundWithBlock { (imageData: NSData?, error: NSError?) -> Void in 

    if let imageData = imageData where error == nil 
    { 
     self.image = UIImage(data: imageData) 
    } 
} 
+0

我對我的作品在最新的解析框架版本昨天拉框架,沒有骰子。 –

+0

檢查編輯@spacemonkey – OscarVGG

+0

做到了。非常感謝您的幫助!感謝您抽出寶貴的時間。 –