我试过关注this和this和this,但是我在从字符串数组中获取数据时遇到了问题。
我的状态设置为
businessHours = : [
"Monday: 7:00 AM – 7:00 PM",
"Tuesday: 7:00 AM – 7:00 PM",
"Wednesday: 7:00 AM – 7:00 PM",
"Thursday: 7:00 AM – 7:00 PM",
"Friday: 7:00 AM – 7:00 PM",
"Saturday: 7:00 AM – 7:00 PM",
"Sunday: Closed"
]
这只会让我得到数组中的第一个元素
ForEach(businessHours.indices) {
Text(self.businessHours[$0])
}
这失败了
ForEach(businessHours.indices) {
Text(self.businessHours)
}
这在控制台中有效
for businesshour in businessHours {
print("Hours: \(businesshour).")
}
我在这里做错了什么?