I have created my own Struct object, that is populated from the Photos framework with each "moment" an image was contained in, and other metadata.
struct MomentImage {
var momentNo : Int
var index : Int
var image : UIImage
}
I would like to populate a tableView, split with:
- Sections, which map to
momentNo - Cells, which map to
index
In tableView(cellForRowAt indexPath), I have printed out:
print("location: \(indexPath.section) and \(indexPath.row)")
But the Section value only ever prints "0". I expected my print statements to occur through all the sections in this table (with my test data, this is actually 13 sections)
How do I filter / retrieve this object at these 2 indices from my array of var moments = [MomentImage]...
Using array.filter { } seems the most obvious way. How do I pass in a 2nd property to check (i.e. momentNo AND index) within the same call?
let filteredassets = assets.filter { $0.momentNo == indexPath.section }
is my current code.
Note, the images need to be encodable, hence extracting from the PHImageManager into a distinct UIImage within a Struct that should itself be encodable.