Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 从表视图中删除解析中的图像_Swift_Uitableview_Parse Platform - Fatal编程技术网

Swift 从表视图中删除解析中的图像

Swift 从表视图中删除解析中的图像,swift,uitableview,parse-platform,Swift,Uitableview,Parse Platform,我正在为我的项目使用parse。对于caneditrowatinexpath . 我在查看文档和示例项目,但没有看到一个地方可以告诉我如何删除。我正在使用下面的代码从解析中删除。然而  我在imageFiles?中遇到错误。它表示使用未定义的标识符 func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath i

我正在为我的项目使用parse。对于
caneditrowatinexpath
 . 我在查看文档和示例项目,但没有看到一个地方可以告诉我如何删除。我正在使用下面的代码从解析中删除。然而  我在imageFiles?中遇到错误。它表示使用未定义的标识符

     func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
    if editingStyle == .Delete {
        let objectToDelete = imageFiles?[indexPath.row] as! PFFile
        objectToDelete.deleteInBackgroundWithBlock {
            (success: Bool, error: NSError?) -> Void in
            if (success) {
                self.loadObjects()
            } else {
            }
        }
    } else if editingStyle == .Insert {
    }
}
我正在将图像转换为NSData,然后转换为PFFile。我正在使用下面的代码检索图像

 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let singleCell:SingleRowCell = tableView.dequeueReusableCellWithIdentifier("mySingleCell")as! SingleRowCell
        singleCell.topsLabel.text = imageText [indexPath.row]
        imageFiles[indexPath.row].getDataInBackgroundWithBlock{
          (imageData: NSData?, error: NSError?) -> Void in
        if imageData != nil {
            let image = UIImage(data: imageData!)
            singleCell.topsImageView.image = image
        }else {
            println(error)
            }}


        return singleCell
        }}

    func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool{
        return true
    }
我删除文件的方法是错误的还是编码错误。
谢谢。

imageFiles是全局变量吗?您好,imageFiles位于同一个文件中,因此即使它是全局变量,也不会有什么区别。如果你有其他错误的想法,我也可以给你看其他的代码。好的,我知道了。我正在使用PFFile保存图像。PFFile不允许用户从一开始就删除它。还有另一种称为PFObjects的类型,但我不确定它是否可以处理图像。imageFiles是全局变量吗?您好,imageFiles在同一个文件中,因此即使它是全局变量也不会有什么区别。如果你有其他错误的想法,我也可以给你看其他的代码。好的,我知道了。我正在使用PFFile保存图像。PFFile不允许用户从一开始就删除它。还有另一种类型称为PFObjects,但我不确定它是否可以处理图像。