Implemented the "numberOfSectionsInData" property and the "numberOfDataItems(in: )" and "dataItem(at: )" functions in the LocationsListViewModel view model.
This commit is contained in:
parent
985e8ffe8e
commit
ea9fea98b3
@ -48,6 +48,7 @@ extension LocationsListViewModel: LocationsListViewModeling {
|
|||||||
// MARK: Properties
|
// MARK: Properties
|
||||||
|
|
||||||
var viewStatusPublisher: Published<LocationsListViewStatus>.Publisher { $viewStatus }
|
var viewStatusPublisher: Published<LocationsListViewStatus>.Publisher { $viewStatus }
|
||||||
|
var numberOfSectionsInData: Int { fetchedResultsController.sections?.count ?? 0 }
|
||||||
|
|
||||||
// MARK: Functions
|
// MARK: Functions
|
||||||
|
|
||||||
@ -71,6 +72,21 @@ extension LocationsListViewModel: LocationsListViewModeling {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func numberOfDataItems(in section: Int) -> Int {
|
||||||
|
guard
|
||||||
|
let sections = fetchedResultsController.sections,
|
||||||
|
sections.endIndex > section
|
||||||
|
else {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
return sections[section].numberOfObjects
|
||||||
|
}
|
||||||
|
|
||||||
|
func dataItem(at indexPath: IndexPath) -> Location {
|
||||||
|
fetchedResultsController.object(at: indexPath)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Enumerations
|
// MARK: - Enumerations
|
||||||
|
Loading…
x
Reference in New Issue
Block a user