UIDocument not saving to file despite indicating success

前端 未结 3 620
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-05 04:45

I\'m trying to open, modify, and save a file in iCloud Drive using UIDocument. When I call save(to:for:completionHandler:) with the file location and u

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-05 04:56

    So according to

    https://developer.apple.com/reference/uikit/uidocument

    It looks like the save function isn't actually for saving a document. My understanding from reading it is that save is only for creating a new document. I understand that you are using the .forOverwriting to just save over it but there may be something in iCloud that wont let the complete overwrite happen.

    In your doSaveAndClose method try calling

    self.saveFile?.close(completionHandler: self.didClose)
    

    by itself. You may have to do some type of if query where you check if the file exist. If it doesn't then call the .save(), else call the .close function. It seems that no matter what when the document it closed it saves changes.

提交回复
热议问题