Latest 1.0.0
License MIT
Platforms ios 9.0

CI Status


To run the example project, clone the repo, and run pod install from the Example directory first. Then run ABExpandableView.xcworkspace which is under /Example folder.


  • Swift 4
  • Xcode 9


ABExpandableView is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'ABExpandableView'


First, import ABExpandableView to your project.

You should have 2 kinds of model objects to use this view that one of them should be section and the other one should be row.

Consider, Section and Row classes are your objects.

class Section: SectionItem {
    var identifier: String!
    var name: String!

    var expanded: Bool = true

    var rows: [RowItem] = [RowItem]()
    var rawRows: [RowItem] = [RowItem]() {
        didSet {
            rows = rawRows
    var selectedRows: [RowItem] = [RowItem]()

class Row: RowItem {
    var identifier: String!
    var name: String!

class MockDataProvider {

    class func createMockData() -> [SectionItem] {
        var array = [SectionItem]()

        let izmir = City()
        izmir.identifier = "35" = "İzmir"
        let bornova = Town(identifier: "1", name: "Bornova")
        let urla = Town(identifier: "2", name: "Urla")
        let konak = Town(identifier: "3", name: "Konak")
        let izmirRawRows = [bornova, urla, konak]
        izmir.rawRows = izmirRawRows

        let istanbul = City()
        istanbul.identifier = "34" = "İstanbul"
        let kadikoy = Town(identifier: "4", name: "Kadıköy")
        let maltepe = Town(identifier: "5", name: "Maltepe")
        let beykoz = Town(identifier: "6", name: "Beykoz")
        let istanbulRawRows = [kadikoy, maltepe, beykoz]
        istanbul.rawRows = istanbulRawRows

        return array


After you create your models, you should open ABExpandableView with injecting those model array.

@IBAction func buttonTapped(_ sender: Any) {
        let cities = MockDataProvider.createMockData()
        let expandableSectionsViewModel = ExpandableSectionsViewModel(cities)
        let expandableSectionViewController = ExpandableSectionsViewController.newInstance(expandableSectionsViewModel)
        expandableSectionViewController.title = "Choose Town(s)"
        expandableSectionViewController.delegate = self
        self.navigationController?.pushViewController(expandableSectionViewController, animated: true)

Here, let ABExpandableView handle the rest.

One last thing;
You can get selected items using the delegation;

    func didSelectItems(_ items: [RowItem]) {
        let names = items.flatMap { $ }.joined(separator: ", ")
        // "Bornova, Kadıköy"


alicanbatur, [email protected]


ABExpandableView is available under the MIT license. See the LICENSE file for more info.

Latest podspec

    "name": "ABExpandableView",
    "version": "1.0.0",
    "summary": "Expandable, collapsible, filterable and single/multi selectable table view.",
    "description": "This pod lets you to list data you want with sections which have ability to expand and collapse. You can also filter rows using searchbar text input. All rows are also selectible.nWhen you complete your data selection, you will have selected ids with the delegation. All these process will let you do your operations with default animations.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "alicanbatur": "[email protected]"
    "source": {
        "git": "",
        "tag": "1.0.0"
    "social_media_url": "",
    "platforms": {
        "ios": "9.0"
    "source_files": "ABExpandableView/Classes/**/*.{c,h,hh,m,mm,swift}",
    "pushed_with_swift_version": "4.0"

Pin It on Pinterest

Share This