我是 swift 新手,我一直在尝试将这组员工映射到一组员工姓名(字符串)。我究竟做错了什么?
这是一个 KMM 项目,因此对象定义是用 Kotlin 编写的
data class Employee( //kotlin
val id:String,
val name:String,
val isHere:Boolean
)
data class Work( //kotlin
val id:String,
val name: String,
var employees: MutableList<Employee>,
val todoToday: Boolean
)
struct SideworkCardView: View {
var work : Work
var body: some View {
VStack(alignment: .leading) {
Text(work.name.capitalized)
.font(.system(size: 25, weight: .medium))
.foregroundColor( .black )
Text(
work.employees.map( { (employee) -> String in
employee.name //ERROR HERE
}).joined(separator: ", ")
)
.font(.system(size: 15, weight: .medium))
.foregroundColor(.black)
}
}
}
错误:“NSArray.Element”(又名“Any”)类型的值没有成员“名称”