How to create a document-based app using FileDocument and DocumentGroup – SwiftUI

preview_player
Показать описание
SwiftUI comes with support for document-based apps, which are apps that let users create, edit, and share documents such as text files. In SwiftUI we’re given two main types to work with: the FileDocument protocol to define what a document in our app looks like, and the DocumentGroup struct that gives us a default scene to let users create, open, and save documents.
Рекомендации по теме
Комментарии
Автор

I think the API has changed since the video was made. FileDocument it seems has now been defined differently:

The code I had to use to make it work is different from yours, Paul:

init(configuration: ReadConfiguration) throws {
if let data = {
text = String(decoding: data, as: UTF8.self)
}
}

func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper {
let data = Data(text.utf8)
return data)
}

markaurelius
Автор

Nice! But how to show a window with document templates to choose? Before creating a document?

cinetagonist
Автор

This is cool but it seems too constrained
If I want to open image files on disk in the app, coreimage them up and export to somewhere else, this looks like it's not for that use case :/

MaxRovensky
Автор

Hi, thanks for your video! I need to read strings and image from an array and convert in a pdf to share. How can I do that? Thanks again!

psacc
Автор

Great tutorial. I'm wondering if we can create a Pages editor in the similar way?

candyman
Автор

Is this the same as the Document based App template?

aneshc
Автор

Do you have Storyboard version of this video?

MaxLK
Автор

Thanks! But how to add a Core Data stack to it?

cinetagonist
Автор

How do you get the file URL when the file is saved/moved/deleted?

fuermosi
Автор

How would this work with Spreadsheets for example?

jorgediazchao
Автор

Looks like they've already deprecated the init and write methods and now use "configurations".

chriswaco
Автор

How to iterate documents in iCloud folder

anandsunku
join shbcf.ru