Post

Replies

Boosts

Views

Activity

Trouble navigation from detail view to grid view (root view) in app using SwiftData
I am writing an Library app that shows a grid. Each grid location shows the book cover and some info about the book. If the user clicks on a cover, the detail view opens. One option that the user has is a delete the book button. This button deletes the book from SwiftData, but the detail page remains populated. The simple way I want to handle this is to have the delete button also return to the grid view (eg root). Here is the relative code from the CurrentView @State private var path = [Book]() var body: some View { NavigationStack(path: $path) { BookListView(sort: sortOrder, searchString: searchText) .navigationTitle("Library") .navigationDestination(for: Book.self, destination: EditBookView.init) .searchable(text: $searchText) Here is the code from the Grid View var body: some View { LazyVGrid (columns: gridLayout) { ForEach(books) { book in NavigationLink(value: book) { GridRow { VStack { Here is the code from the Detail View var body: some View { Form { VStack (spacing: 0){ BookImageView(book: book) } TextField("Title", text: $book.title) Button("Go Back to ListView", action: { // Action to perform }) } .navigationTitle("Edit Book") .navigationBarTitleDisplayMode(.inline) } // Form } // some View Can you provide the code for the button "Go Back to Last View"
0
0
82
1w
Cocoa Touch: Writing files to user's cloud storage
In my app the user can go to a cloud provider, such as Dropbox, click on an appropriate CSV or TXT file and open it in my App. My App converts the incoming data to a specific doc format (it contains the data in the CSV file plus data how various parameters the user input to process the data). The App removes the path extension and provides a new path extension. I would like to write this file back to the user's folder in the cloud provider (eg Dropbox). Is this possible just using file manager calls, or do I have to use the Dropbox API. The issue is that I don't want to have to write various versions for other cloud providers such as OneDrive and Box. My other option is the save the file with the modified format for my App in the App Document directory. However, when the user goes back to the Document Browser, it is still shows the Dropbox area. Is there a way to tell the Document Browser which location you want it to return to (eg the sandboxed Document directory.
1
0
316
Oct ’20