I cannot seem to figure this simple error out. Any help would be appreciated.
Here is the line of code which has an issue, as well as the error message I receive:
fun.dataSource = TestArrayData[result]
<------Cannot subscript a value of type '[TestDataModel]' with an argument of type 'TestDataModel'
I'm also getting this error message for the same line: 1. Overloads for 'subscript' exist with these partially matching parameter lists: ((UnboundedRange_) -> ()), (Int), (Range<Int>), (Range<Self.Index>)
Here is the full brick of code:
func fun(at index: Int) -> FunView {
let fun = FunView()
let myArray = [generateRandomNumber(0, 5, 1)]
var myString = ""
_ = myArray.map{ myString = myString + "\($0)" }
let ayyy = (myString as NSString).integerValue
let myInt = Int?(ayyy)
var ayyString = String(ayyy)
let result = (TestDataModel(text: ayyString))
fun.dataSource = TestArrayData[result]
return fun
}
Following up for @Paulw11 , the TestArrayData
is the following:
var TestArrayData = [TestDataModel(text: "One"),
TestDataModel(text: "Two"),
TestDataModel(text: "Three"),
TestDataModel(text: "Four"),
TestDataModel(text: "Five"),
TestDataModel(text: "Six")]