Created
November 9, 2022 17:09
-
-
Save BetterProgramming/f1d1ae28e579bd4f64f738d6e45bdc1b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func getTimeline(in context: Context, completion: @escaping (Timeline<Entry>) -> ()) { | |
var entries: [QuoteEntry] = [] | |
// Generate a timeline consisting of five entries minute apart, starting from the current date. | |
let currentDate = Date() | |
for hourOffset in 0 ..< 5 { | |
let quote = quoteManager.getSingleQuote() | |
let entryDate = Calendar.current.date(byAdding: .minute, value: hourOffset, to: currentDate)! | |
let entry = QuoteEntry(date: entryDate, quote: quote) | |
entries.append(entry) | |
} | |
let timeline = Timeline(entries: entries, policy: .atEnd) | |
completion(timeline) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment