AssistoLab / DropDown

A Material Design drop down for iOS
MIT License
2.44k stars 622 forks source link

How can i add my array of Modal to Datasource #256

Open dilipiOSDeveloper opened 4 years ago

dilipiOSDeveloper commented 4 years ago

I have successfully added DropDown to my project its working fine with static data

dropDowns.dataSource = ["A","B","C""]

        dropDowns.show()
        dropDowns.selectionAction = { [weak self] (index,item) in
            self?.lblData.text = item
        }

Above code is working fine , but the issue is with dynamic data from api call

I have array .... var arrayState = [StateModal]()

Modal :

class StateModal{

    var idState :String?
    var stateName :String?

    init(idState:String,stateName:String) {
        self.idState = idState
        self.stateName = stateName
    }
}

but when i assign dynamic data is shows error

dropDowns.dataSource = [StateModal] it shows error : Cannot assign value of type '[StateModal].Type' to type '[String]'

mmswide commented 3 years ago
var modalInfos: [String] = []
for modal in modals {
      let modalInfo = "\(modal.stateName!)"
      modalInfos.append(vehicleInfo)
}
dropDowns.dataSource = madalInfos
dilipiOSDeveloper commented 3 years ago

modalInfos

Pls check i am assigning Modal array not array of string