2017-03-06 15 views
0

请我有与标识符表视图didSelectRow方法执行赛格瑞每个i抽头单元时间的记忆增加泄漏存储器与performSegue与标识符迅速3

以下内容的问题是我的代码:

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 
    // firstly i need to check if edit button is true so i can select cell 
    if isShowToolBar { 
     // her for hold selected index 
     let cell = tableView.cellForRow(at: indexPath) as? MovieDownloadedTableViewCell 
     if let cell = cell { 
     cell.movieCheckMarkImageView.isHidden = false 
     cell.movieEmptyCircleImageView.isHidden = true 
     operationDocumentDirectoryObject.dictionaryHoldIndexCellForDisplayWhichCellSelected.updateValue(indexPath.row, forKey: indexPath.row) 
     // start hold URL 
     operationDocumentDirectoryObject.dictionaryForHoldURLSelected.updateValue(operationDocumentDirectoryObject.arrayOfMovieURL![indexPath.row], forKey: indexPath.row) 
     }// end the if let cell 

    }else{ 
     // her for show the content folder 
     let cell = tableView.cellForRow(at: indexPath) as? MovieDownloadedTableViewCell 
     if let cell = cell { 
      if cell.fetchURL!.pathExtension == "" { 
       performSegue(withIdentifier: "ShowFolder", sender: indexPath.row) 
      }else{ 

      // playing the video 
     performSegue(withIdentifier: "PlayingMovie", sender: cell.fetchURL!.lastPathComponent) 

      }// end the if for check path extenstion 
     }// end the if let cell 
     cell = nil 

    }// end the if for the isShowToolbar 

} 

上述方法具有内存泄漏在执行赛格瑞和引起与增加存储器(如果cell.fetchURL!.pathExtension ==“”)还使存储器泄漏

override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 
    if segue.identifier == "MoveFile" { 
     if let destination = segue.destination as? MoveMovieViewController { 
      destination.operationDocumentDirectoryObject.dictionaryForHoldURLSelected = self.operationDocumentDirectoryObject.dictionaryForHoldURLSelected 
     } 

    }else if segue.identifier == "ShowFolder" { 
     if let destination = segue.destination as? ShowContentFolderMovieViewController { 
      if let fetchIndex = sender as? Int { 
       destination.operationDocumentDirectory.folderName = self.operationDocumentDirectoryObject.arrayOfMovieURL![fetchIndex].lastPathComponent 
      } 
     } 
    }else if segue.identifier == "PlayingMovie" { 
     // make an object for the playing video view controller 
     if let destination = segue.destination as? PlayingMovieViewController { 
      if let movieName = sender as? String { 
       destination.operationDocumentDirectory.movieName = movieName 
      } 

     } 
    }// end the condition for the segue 
} 

虽然DEINIT是在视图控制器呼叫成功,但我还有泄漏并提高内存

什么是我的错误代码,请帮助?

非常感谢你

回答

0

我怀疑你在你的代码的某个地方有很强的参考周期 - 尽管不是在你已经尽可能我可以告诉张贴位。但是,你说你的deinit被称为成功。您是否检查过您所期望的所有视图控制器的deinits是否在预期时间被调用(例如当您关闭PlayingMovieViewController或ShowContentFolderMovieViewController时)?观察用于deinit打印语句的xcode调试控制台以检查内存中的适当版本是最好的方法。尽管如此,你的内存泄漏可能来自其他地方。你应该注意代码中其他地方的强引用(可能是委托人持有发送者对象?)。

+0

你的意思是我的segue是这样,是正确的,我必须寻找另一种方法吗?当我使用仪器工具它是执行segue它指向它需要4.45 mib我不知道为什么,我必须释放所有意见deinit? – Mustafa

+0

视图控制器的所有deinit方法都调用成功,但正如我告诉你的,当我在仪器工具中检查它时,它指向我的performSegue带标识符它需要4.45 mib – Mustafa

+0

您能张贴仪器工具的屏幕截图向你展示? – hvasam