I'm new to Swift and I am having a few problems with retrieving an object in an array by property.
Please note, I am using Swift 2.0.
I have the following array;
//Dummy Data prior to database call:
static var listPoses = [
YogaPose(id: 1, title: "Pose1", description: "This is a Description 1", difficulty: Enums.Difficulty.Beginner, imageURL: "Images/Blah1"),
YogaPose(id: 2, title: "Pose2", description: "This is a Description 2", difficulty: Enums.Difficulty.Advanced, imageURL: "Images/Blah2"),
YogaPose(id: 3, title: "Pose3", description: "This is a Description 3", difficulty: Enums.Difficulty.Intermediate, imageURL: "Images/Blah3"),
YogaPose(id: 3, title: "Hello World", description: "This is a Description 3", difficulty: Enums.Difficulty.Intermediate, imageURL: "Images/Blah3")
]
I now have a method that I'd like to return an object by Id. Can someone please advise how I would do so ... e.g. where listPose.Id === Id;
//Returns a single YogaPose By Id:
class func GetPosesById(Id: Int) -> YogaPose{
if(listPoses.count > 0){
return listPoses() ...
}
}