Skip to content

Instantly share code, notes, and snippets.

@BetterProgramming
Created November 9, 2022 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BetterProgramming/560e27cc9c3e1d7b61681c6831322fd9 to your computer and use it in GitHub Desktop.
Save BetterProgramming/560e27cc9c3e1d7b61681c6831322fd9 to your computer and use it in GitHub Desktop.
struct Provider: TimelineProvider {
private let quoteManager = QuoteManager()
[...]
func getSnapshot(in context: Context, completion: @escaping (QuoteEntry) -> ()) {
if context.isPreview {
let quote = Quote(quote: "Roses are red", author: "Nobody knows")
completion(QuoteEntry(date: Date(), quote: quote))
} else {
let quote = quoteManager.getSingleQuote()
completion(QuoteEntry(date: Date(), quote: quote))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment