I have 2 structs which takes, in a list of Courses.
struct Course : Decodable {
let CourseName : String;
let EntryRequirements : String;
}
struct WebsiteDescription : Decodable {
let FullProgramName :String
let ProgramName : String;
let Courses : [Course]
}
These structs are loaded with JSON
I've implemented a UISearchController to actually Search through the Course Name.
I have no idea how to reference to the Struct Course from within the WebsiteDescription which contains the course names.
Arrays that I had used to contain the WebsiteDescription
var allCourses = [WebsiteDescription]()
var filteredCourses = [WebsiteDescription]()
I have tried to filter it with this method
func updateSearchResults(for searchController: UISearchController) {
if searchController.searchBar.text! == "" {
filteredCourses = allCourses
acTableView.reloadData()
} else {
filteredCourses = allCourses.filter { $0.ProgramName.lowercased().contains(searchController.searchBar.text!.lowercased()) }
}
self.acTableView.reloadData();
}
It filters the general programme name, but I would actually want to filter using the CourseName in the struct Course.
Thank you in advance.
When I search for mentoring, the whole section of ShortCourses Appears when only 'Mentoring' should appear.
Mentoring is the Course Name