In one class named DataService.swift I have created an array of struct's as follows...
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
}
}
I want to call the Workout videoCode: "_kAlQ5Bh5aY" from each struct in the bicepWorkout array to a different class. Does anyone have an idea of how this can be done?
Thanks in advance!
You can try
let work1 = DataService.instance.bicepWorkouts[0]
print("\(work1.videoCode)")