在一个名为DataService.swift的类中,我创建了一个struct的数组,如下所示......
class DataService {
static let instance = DataService()
private let bicepWorkouts = [
Workout(title: "Bicep Machine", imageName: "gloves.png", timeLength: "2:43", videoCode: "_kAlQ5Bh5aY", level: "Beginner", type: "Strength", likes: "5 Likes"),
Workout(title: "Bicep Curl", imageName: "sixplates.png", timeLength: "1:44", videoCode: "_kAlQ5Bh5aY", level: "Beginner", type: "Strength", likes: "5 Likes")
]
func getBicepWorkouts() -> [Workout] {
return bicepWorkouts
}
}
我想调用锻炼videoCode:" _kAlQ5Bh5aY"从bicepWorkout数组中的每个结构到另一个类。 有没有人知道如何做到这一点?
提前致谢!
答案 0 :(得分:0)
你可以尝试
let work1 = DataService.instance.bicepWorkouts[0]
print("\(work1.videoCode)")