UIDocumentBrowserViewController app : Refresh no of items in each folder

92 views Asked by At

I am creating an UIDocumentBrowser based app and notice this issue:

  • Say I am viewing these folders:- Folder 1 -> 20 items Folder 2 -> 50 items ....

e.g If my app deletes all items in say Folder 2, "50 items" is still listed as in Folder 2. How to force a refresh so that the no. of items show the correct "0 items"??

Thanks

Edited to add screenshots with issue. I create a "dummy" UIDocumentBrowser app to show the issue. In the app, I added a button to delete "Selected files".

Initial state with folder F1 8 items

Screenshot with selection of 8 items in folder F1 and then choosing the "Test-Delete" button

All files are deleted in folder F1

Go back one folder up and folder F1 still says 8 items!!!

Go up one more folder and then back down, and folder F1 correctly shows 0 items

The code to delete the items is:-

func Delete_button_action(documentURLs: [URL]) {
    for item in documentURLs {
        do {
            try FileManager.default.removeItem(at: item)
            print("Item=\(item) deleted")
        } catch {
            print("Error in removing item \(item); error=\(error.localizedDescription)")
        }
    }
}
0

There are 0 answers