I have created an app that stores airplane inspection and maintenance history, including any photographs and other documentation. In a view controller, a user selects a maintenance requirement to view the history which results in a collection view being loaded displaying all the history by date, in collection view cells. If the user taps on a collection view cell, code is called up to go and get the image data and display it in a tableview format.
However, I don’t think I am retrieving the information from Cloud Firestore properly as I am running into a number of issues that I have spent many hours over the past few weeks trying to resolve.
I have gone back through the lessons and googled solutions and I have included adding completion blocks and running the code on an asynchronous thread using dispatchqueue.global.async.
I obviously don’t understand something basic based on the problems I am seeing and I am hoping that someone on here could give me a hand by reviewing my code.
The first time the user taps on the collection view cell, a blank cell comes up and sometimes it takes several taps before the user is taken to a tableview to view the images. This tells me that the image data hasn’t finished loading before the table view is loaded. I ran into this problem before on another view controller and was able to resolve it with reloading the view in the main thread. But that hasn’t helped with this problem.
I noticed that sometimes the following error is displayed after the images are displayed:
[BackgroundTask] Background Task 20 (“GTMSessionFetcher-firebasestorage.googleapis.com”), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_ for your task in a timely manner to avoid this.
If someone is willing to review my code I would really appreciate any advice they can give me on how to properly download and display images. Here is the link:
The first page of code is the view controller that displays the collection view cells with the image history. It includes a “getImage function” that is called up when the collection view cell is tapped.