[Solved] Store label information into history table | Swift | Xcode


So all you really need is a data structure that allows you to store your data and allow it to be passed between view controllers. The simple approach would be to have:

struct PictureDetail {
  photo: UIImage
  text: String
}

Depending on the volume/size of images, you’d probably better actually holding the photos as files and just keeping the file path in the struct and have a calculated property that retrieves it from disk:

struct PictureDetail {
  photoPath: URL
  text: String
  photo: UIImage {
    // load photo from URL & return 
  }
}

The you need some form of collection to hold all your data and to allow it to be injected into wherever it is needed

class DataModel {
  var pictureData: [PictureDetail] = []

  func addPictureDetail(picture: UIImage, text: String) {
    //save picture to disk and obtain URL
    pictureData.append(PictureDetail(url: url, text: text)
}

Then instantiate the data model in your initial view controller

let dataModel = DataModel()

And then have a DataModel property in the other VCs, and inject the value during your prepare(for segue: IUSegue) method.

2

solved Store label information into history table | Swift | Xcode