PDFKit iOS 11 , Displaced Pdf

I have This Code for Read UITable

var documents = PDFDocument

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! BookshelfCell
        
        
        
        let document = documents[indexPath.row]
        
        
        
        
        if let documentAttributes = document.documentAttributes {
            
            if let title = documentAttributes["Title"] as? String {
                
                cell.title = title
                
            }
            
            if let author = documentAttributes["Author"] as? String {
                
                cell.author = author
                
            }
            
            if document.pageCount > 0 {
                
                if let page = document.page(at: 0), let key = document.documentURL as NSURL? {
                    
                    cell.url = key
                    
                    
                    
                    if let thumbnail = thumbnailCache.object(forKey: key) {
                        
                        cell.thumbnail = thumbnail
                        
                    } else {
                        
                        downloadQueue.async {
                            
                            let thumbnail = page.thumbnail(of: CGSize(width: 40, height: 60), for: .cropBox)
                            
                            self.thumbnailCache.setObject(thumbnail, forKey: key)
                            
                            if cell.url == key {
                                
                                DispatchQueue.main.async {
                                    
                                    cell.thumbnail = thumbnail
                                    
                                }
                                
                            }
                            
                        }
                        
                    }
                    
                }
                
            }
            
        }
        
        return cell
        
    }

I have Save the PDFs like this

private func refreshData() {

    let fileManager = FileManager.default
    let documentDirectory = fileManager.urls(for: .documentDirectory, in: .userDomainMask)[0]
    
    let contents = try! fileManager.contentsOfDirectory(at: documentDirectory, includingPropertiesForKeys: nil, options: .skipsHiddenFiles)
    
    documents = contents.flatMap { PDFDocument(url: $0) }

    tableView.reloadData()

}

Now I want to Displaced the Pdf’s in Uitable

override func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {

let movedObject = self.documents[sourceIndexPath.row]

documents.remove(at: sourceIndexPath.row)



documents.insert(movedObject, at: destinationIndexPath.row)

refreshData()

}

But After the code goes to refreshData()
the Pdf Back to Previous mode (Previous Place)
Maybe I will Change the refreshData() Part and Save the Pdf Method Please Help me

@miladbigle. Thanks very much for your question!

Often times if you have a lot of code that you need to go through in order to debug, I would personally recommend posting your question to StackOverflow. It is an essential resource for all developers, and there are brilliant people who are able to provide you with a solution…often times within 24 hours!

I hope this helps!

All the best!

Thanks
But Near 1 month ago send this question and I can’t find a response to this issue

Can you help me about How to resolve this issue it’s very important in my work

if you can find the solutions with pay systems I will pay for this issue in this forums

This topic was automatically closed after 166 days. New replies are no longer allowed.