I’m working with UIDocument to store a PDF file. This is code I use for saving a file.
Firstly, I created a document with URL.
let document = UIDocument(fileURL: url)
Second, I opened a document.
document.open(completionHandler: { (success) in
if success {
// open successfully
}
})
And finally, I saved the document.
document.close(completionHandler: { (success) in
if success {
document.save(to: url,
for: .forOverwriting,
completionHandler: { (success) in
if success {
print("Saved file successfully")
}
})
}
})
This code works well with a small file size. But if it’s a large file like 100MB, it takes around 2-5 minutes to save the file. Is there a way to save file with the changes only? Or create an auto save function triggered whenever the user edit the file?
I tried to find other UIDocument.SaveOperation but seems there’re only 2 options: create a new one or overwrite the old file which doesn’t match my expectation.
1