diff --git a/Example/IGListKitExamples/SectionControllers/HorizontalSectionController.swift b/Example/IGListKitExamples/SectionControllers/HorizontalSectionController.swift index f6b5d36..34be10f 100644 --- a/Example/IGListKitExamples/SectionControllers/HorizontalSectionController.swift +++ b/Example/IGListKitExamples/SectionControllers/HorizontalSectionController.swift @@ -50,11 +50,8 @@ class HorizontalSectionController: IGListSectionController, IGListSectionType, I //MARK: IGListAdapterDataSource func objects(for listAdapter: IGListAdapter) -> [IGListDiffable] { - var numbers = [Int]() - for i in 0..<(number ?? 0) { - numbers.append(i) - } - return numbers as [IGListDiffable] + guard let number = number else { return [] } + return (0.. IGListSectionController { diff --git a/Example/IGListKitExamples/ViewControllers/SearchViewController.swift b/Example/IGListKitExamples/ViewControllers/SearchViewController.swift index 30ee97a..5d959e5 100644 --- a/Example/IGListKitExamples/ViewControllers/SearchViewController.swift +++ b/Example/IGListKitExamples/ViewControllers/SearchViewController.swift @@ -48,13 +48,8 @@ class SearchViewController: UIViewController, IGListAdapterDataSource, SearchSec //MARK: IGListAdapterDataSource func objects(for listAdapter: IGListAdapter) -> [IGListDiffable] { - var items: [IGListDiffable] = [searchToken] - for word in words { - if filterString == "" || word.lowercased().contains(filterString.lowercased()) { - items.append(word as IGListDiffable) - } - } - return items + guard filterString != "" else { return [searchToken] + words.map { $0 as IGListDiffable } } + return [searchToken] + words.filter { $0.lowercased().contains(filterString.lowercased()) }.map { $0 as IGListDiffable } } func listAdapter(_ listAdapter: IGListAdapter, sectionControllerFor object: Any) -> IGListSectionController {