2017-03-06 14 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