I have a string - "productRaw" which I am splitting up to show in separate sectionData
cells, whilst under the same "Item 1" cellData
table view. This is the code I am using to split up the String and add each separate part to a separate sectionData
cell.
let group_array = document["product"] as? [String] ?? [""]
let productName1 = group_array.first ?? "No data to display :("
let productRaw = "\(productName1)"
let componentsRaw = productRaw.components(separatedBy: ", ")
var product = [String: String]()
for component in componentsRaw {
let keyVal = component.components(separatedBy: ": ")
product[keyVal[0]] = keyVal[1]
}
if let productName = product["Product Name"], let listingPrice = product["Listing Price"], let briefDescription = product["A brief description"], let productURL = product["Product URL"], let activeUntil = product["Listing active until"] {
self.tableViewData = [cellData(opened: false, title: "Item 1", sectionData: [productName], [listingPrice], [briefDescription], [productURL], [activeUntil])]
}
Where I am declaring the individual cells I want to be shown for the first section - "Item 1", when I only use [productName]
in my sectionData
then this compiles without any issues. However when I also add , [listingPrice], [briefDescription], [productURL], [activeUntil]
to my sectionData
I receive the following error for the [cellData(opened:
syntax.
Extra arguments at positions #4, #5, #6, #7 in call
So my question is, why am I receiving the above error and what can I do to resolve it?