have two quote dictionaries I'm trying to append after an in-app purchase. I have tried several different methods to append the dictionaries together but I'm still getting an error "No exact matches in call to instance method 'append'" I have established variables for each array to then append the array within the struct. Any thoughts? Is there a better method I should use to add the quotes from the array called QuoteDetails2 to the initial array QuoteDetails?
Here is the code I'm trying to correct:
var topQuotes = [QuoteDetails]()
var additionalQuotes = [QuoteDetails2]()
public struct QuoteProvider {
static func all() -> [QuoteDetails] {
return
[
QuoteDetails(
id: “1”,
texts: “High school is fun”,
authors: “SM”
),
QuoteDetails(
id: “2”,
texts: “Middle School is fun”,
authors: "A. Philip Randolph"
),
QuoteDetails(
id: “3”,
texts: “The playground is fun”,
authors: "Booker T. Washington"
),
QuoteDetails(
id: “4”,
texts: "Hold on to your dreams of a better life and stay committed to striving to realize it.",
authors: “KJ”
)
]
}
static func all2() -> [QuoteDetails2] {
return [
QuoteDetails2(
id: "1",
texts: "The cat ran fast”,
authors: " ME”
),
QuoteDetails2(
id: "2",
texts: “The dog ran fast.”,
authors: " ME”
),
QuoteDetails2(
id: "3",
texts: "End life problems”,
authors: “ME”
)
]
}
func showPremiumQuotes() {
if UserDefaults.standard.bool(forKey: "premiumQuotes") == true {
topQuotes.append(contentsOf: additionalQuotes)
}
}
/// - Returns: A random item.
static func random() -> QuoteDetails {
let allQuotes = QuoteProvider.all()
let randomIndex = Int.random(in: 0..<allQuotes.count)
return allQuotes[randomIndex]
}
}