presenting form input into a table view - swift

so I am trying to show a table view of booking slots and the details the user have chosen, I have tried linking an add button to the form using a segue but have failed (it was the question I have previously asked)
Hence, I was thinking if this would be feasible and how I can do it
form input will be shown on another vc eg "u have successfully booked (date) and am slot)
I will get my data there to be shown in the table view
would that be feasible how can I do that? also I have used firebase Firestore database
or any references I can refer to that u guys know of?
THANK YOU

Related

SwiftUI + Firestore - refresh previous view after updating data in modal sheet

Say you have a view that displays a list of items. Clicking the item opens a modal sheet that allows the user to edit the item. On saving the sheet, the data is sent to the database to update and, on completion, the sheet is dismissed.
What's the best practice for updating the first view with the list of items? In my app, I'm currently using the "onDismiss" method to refresh the data from my cloud database (firestore).
However, there are cases when this doesn't work well. For example, if there's a cloud function that needs to run before the data is visible, then the data doesn't appear on the first refresh.
Is there a best practice for handling these types of updates?

Entering data directly via table view swift 4

I’m having a play about with table views and saving data. I’ve managed to created an add button where you can add some data to a table view (like a to do list app) and it saves in user defaults. However, I can’t seem to figure out how to add and save data directly just by pressing an empty row in the table view. Basically, I would like to know how to add data and display data on a table view just like the stock To Do and Reminders app from Apple.
I’m working with Swift 4.
Any help or code examples would be much appreciated!

Saving the state of my UITable View

i have a checklist that is on a UITable View. The user can add/delete cells and check them and uncheck them. I need some assistance with saving the state of the checklist when the page is left, becuase when the user adds a new cell, leaves the page, and returns, the table view is back in the original state i had made it be in! Does someone know my problem? Thanks Guys :D
-Kurt
What you appear to be missing is that adding or deleting a row from your table does not update your source array. Typically when working with a UITableview there are three steps you must perform:
add or remove the tableview cell
update your source array (presumably adding or deleting objects in your context)
save your context to commit the changes
This is assuming you are using Core Data for persistent store. If you are saving in memory than you are likely done at step 2.
I suggest you review the UITableView Class reference, look over the examples and step through a tutorial before trying to stumble through the process.

Editing Records with MVVM/MVVM-Light

I have created a very simple wpf app with mvvm light.
I have rows in a list view, these are templated representations of Book objects.
I can click a row, then click an edit button, this button loads a new window and sends the new window the book to edit (using mvvm-light's Messenger).
The issue I have is when I edit the record in my new window the data on the main form is updated. The text boxes are bound to the object received via the Messenger.
I know this is because I have essentially passed a reference to the same Book object around the place, therefore I update in one place.. and voilà it updates on the main page too.
What I would like to know is.. is there a standard way/method/concept to achieve what I am trying to do? i.e. create an "edit" page/screen with the option of discarding the edits?
thanks.
Could you make your entity implement ICloneable and create a clone for editing?

My data source is being changed out from under a UITableView

I have an app based on a tab bar and data retrieved from the Internet. The main tab shows a map and one of the other tabs shows incidents around the center point of the map displayed using a UITableView. If the user moves the map and then moves to the incidents page, I need to refresh the list of incidents displayed in the table. To do this I request the incidents in viewWillAppear:animated: and when that completes (asynchronously) I call the table view's reloadData method.
This works beautifully unless the user taps between the tabs quickly (e.g. display incidents, move to map, move map, move back to incidents, move back to map, etc.). At some point the incidents data source (an NSArray) is modified while the table view is trying to access it.
Here is a question that is similar:
UITableView Crashes if Data Source Is Updated During Scrolling
One of the solutions for that question describes a solution at a high level that is exactly what I want: Freeze the data source while the table is being updated. The thing I can't figure out, however, is when to unfreeze the data source. The problem is I can't find any way to be notified when the table is done being updated.
Any ideas? How do I freeze the data source while the table is being updated and then unfreeze it once the table is done being updated?
Although I'd really like to receive a notification when the table view is done accessing the data source, I found that my problem was due to modifying the data container from the work thread. The answer to this question led me to the solution:
Refreshing XML data and updating a UITableView
What I do now is fill a separate array in the worker thread and then perform a selector on the main thread to swap the updated data into the data container used by the table view.
The problem is I can't find any way to
be notified when the table is done
being updated.
I think you can assume that the data is done being loaded by checking in tableView:cellForRowAtIndexPath: to see if the last row has been loaded.
I haven't tested it, just making an assumption based on the API