Adding Firebase to existing iOS app

I have followed the UIKit section of this Apple iOS Dev Tutorial, up to and including the Saving New Reminders section. The tutorials provide full code for download at the beginning of each section.

But, I want to get Firebase involved. I have some other Firestore projects that work, but I always thought that I was doing something not quite right, so I'm always looking for better examples to learn from.

This is how I found Peter Friese's 3-part YT series, "Build a To-Do list with Swift UI and Firebase". (https://bit.ly/2UaLUC3) While I'm not using SwiftUI, I figured that the Firestore code should probably work with just a few changes, as he creates a Repository whose sole function is to interface between app and Firestore. No UI involved.

So, following his example, I added a ReminderRepository. It doesn't work, but I'm so close.

The UITableView looks empty but I know that the records are being loaded.

Stepping through in the debugger, I see that the first time the numberOfRowsInSection is called, the data hasn't been loaded from the Firestore, so it returns 0. But, eventually the code does load the data. I can see each Reminder as it's being mapped and at the end, all documents are loaded into the reminderRepository.reminders property. But I can't figure out how to get the loadData() to make the table reload later.

As a temporary solution, I've aded a UIRefreshControl. When I launch and get the blank table, I pull to refresh, and voilà, there's my data. But, I'm trying to get the list to display immediately and also refresh when I add new Reminders. Modifying existing reminders updates the table correctly.

Help?

Same question on StackOverflow

Accepted Answer

I also posted on StackOverflow a few days earlier. Mr. SwiftOak led me to a working solution. See link above.

Adding Firebase to existing iOS app
 
 
Q