I am trying to pass my custom struct ILT
through pushControllerWithName()
so I can pass it to the next screen in my watchOS 2 app. ILTList
is an array of ILT
types, and the pushControllerWithName()
is happening when the user taps on a row in the table, which has its' rows fed from ILTList
.
ILTList is initialised with var ILTList = [ILT]()
, and the ILT struct is as follows:
struct ILT {
let homeworkID: Int
let title: String
let subject: String
let teacher: String
let teacherCode: String
let studentID: Int
let description: String
let due: Double
let status: String
let hasAttachments: Bool
}
And this is where the tap occurs:
override func table(table: WKInterfaceTable, didSelectRowAtIndex rowIndex: Int) {
print(ILTList[rowIndex])
let context:AnyObject = ILTList[rowIndex]
self.pushControllerWithName("showILT", context: context)
}
With this code I get
Cannot subscript a value of type '[ILT]'
When I change context:AnyObject
to just context
or context:ILT
, it says:
Cannot convert value of type 'ILT' to expected argument type 'AnyObject'?
What am I missing here?