I created two realm Object classes called : Master and Courses
class Master : Object , Identifiable {
@objc dynamic var id = UUID()
@objc dynamic var name : String = ""
var courses = List<Course>()
}
class Course : Object , Identifiable {
@objc dynamic var id = UUID()
@objc dynamic var name : String = ""
var parentMaster = LinkingObjects(fromType:Master.self , property: "courses")
}
ViewModel :
class AppState : ObservableObject {
@Published var allmasters : [Master] = []
}
I have a simple function to return courses for each master here :
func input(index: Int) -> List<Course> {
return appState.allmasters[index].courses
}
My problem is : what is the datatype of return for function?? I put List<Course> as a return type but the compiler give me this error :
Generic type 'List' specialized with too few type parameters (got 1, but expected 2)