I have a class for quotes that contains an array full of quotes. The code below shows two. Each quote has an author, attribution, and Bools for hasSeen
and hasSaved
.
I want to show one random quote at a time. When the user refreshes the screen, they get another quote. When I put .randomElement()!
on the array and print the results, I get appName.Quote
.
Is there a way to access a random quote from this array? I want to be able to show the text and attribution to the end user.
var quotes:[Quote] = [
Quote(
quoteText: "The only way to make sense out of change is to plunge into it, move with it, and join the dance.",
quoteAttribution: "Alan Watts",
hasSeen: false,
hasSaved: false),
Quote(
quoteText: "Luck is what happens when preparation meets opportunity.",
quoteAttribution: "Seneca",
hasSeen: false,
hasSaved: false)
]