有这段代码(//错误本身写完之后)
struct CurrentData {
let sliksLable: String
let numbeLable: String
let nameLable: String
init?(currentDataData: CurrentDataData){
nameLable = currentDataData.company.employees.first?.name ?? ""
numbeLable = currentDataData.company.employees.first?.phoneNumber ?? ""
sliksLable = currentDataData.company.employees.first?.skills //Cannot assign value of type '[String]?' to type 'String'
}
}
我创建了带有标签的应用程序,您需要将数据从服务器传输到该标签,数据如下所示:
{
company: {
name: "Avito",
employees: [
{
name: "John",
phone_number: "769453",
skills: [
"Swift",
"iOS"
]
},
{
name: "Diego",
phone_number: "987924",
skills: [
"Kotlin",
"Android"
]
},
{
name: "Alfred",
phone_number: "452533",
skills: [
"Objective-C",
"Android",
"Photoshop"
]
},
}
}
底线是一个简单的错误类型的变量 let sliksLable: String,它应该是 let sliksLable: [String]