A means of accessing the file system in a SwiftUI environment, conveniently.
Let's assume you have a data type called 'Project'.
struct Project: Codable, Equatable, Container {
let name: String
// See wiki/typical-implementation
}
By conforming to the above protocols, you may now create Directory<Project>
or PhotosDirectory<Project>
.
struct ContentView: View {
@StateObject var store: Directory<Project>
var body: some View {
List {
ForEach(store.fetchedItems) { project in
// do something
}
}
.onAppear(perform: {
// store.fetchAndWait()
Task {
await store.fetch()
}
})
}
// stores permanently to disk
// triggers UI re-render
private func addProject() {
let project = Project(name: "Project " + UUID().uuidString)
try! store.append(project)
// See wiki/useful-api for additional functionality.
}
}
NSFilCoordinator
directly.Use the Swift Package Manager documentation.
link |
Stars: 1 |
Last commit: 1 year ago |
See Changelog.
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics