I\'m developing a iOS 14 Widget extension.
I have 3 images to show in loop and creating a Timeline to show those images.
func getTimeline(in context: Conte
Constucting timeline you need to specify explicit entry date for each entry. The policy parameter is for recreating next timeline.
So your getTimeline
should look like
func getTimeline(in context: Context, completion: @escaping (Timeline<Entry>) -> ()) {
var entries: [ImageEntry] = []
let currentDate = Date()
for i in 1 ..< 4 {
let imageNumber = String(i)
let currentImage = "image_" + imageNumber
let entryDate = Calendar.current.date(byAdding: .minute, value: (i-1)*5, to: currentDate)!
let entry = ImageEntry(date: entryDate, image: currentImage)
entries.append(entry)
}
let timeline = Timeline(entries: entries, policy: .atEnd)
completion(timeline)
}