Created
November 9, 2022 17:08
-
-
Save BetterProgramming/560e27cc9c3e1d7b61681c6831322fd9 to your computer and use it in GitHub Desktop.
This file contains 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
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