dimanche 24 novembre 2019

How to exclude condition checking for added row in tableviewcell in swift?

Tableview displaying according to its count but for one category i am adding extra row... here i don't need minLength, maxLength condition checking for that added row textfield text.. but the added row also taking the orginal textfield min, max values. but i dont need that values.. please help me in the below code.

here is the code:

here i am adding extra row:

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

if section == 0 {

    self.rowCount = selectedBiller?.bcustomerparms.count ?? 0
    if selectedBiller?.bcategoryname == "Mobile Postpaid"{

        return  self.rowCount! + 1
    }
    else{
        return selectedBiller?.bcustomerparms.count ?? 0
    }
}
return 1
}

here i am adding extra row text Amount

and taking textfield text count condition according to json given min, max values, these values also applying to added textfild text Amount, but i dont need orginal textfield min,max values to added row text

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

if indexPath.section == 0 {

    cell = tableView.dequeueReusableCell(withIdentifier: "textfieldCell", for: indexPath) as? BillerTableViewCell
    cell?.searchTextfield.delegate = self

    if self.rowCount! - 1 >= indexPath.row
    {
        if let customerDetail = selectedBiller?.bcustomerparms[indexPath.row] {
            alertParam = customerDetail.paramName
            cell?.searchTextfield.text = alertParam
            if var priceOfProduct: String = customerDetail.minLength {
                alertMinL = Int(priceOfProduct)
            }
            if var priceOfProduct: String = customerDetail.maxLength {
                alertMaxL = Int(priceOfProduct)
            }
        }
        else {
            cell?.searchTextfield.text = "missing data"
        }
    }
    else{
        cell?.searchTextfield.text = "Amount"//no need min, max vales
    }
}
return cell!
}

in button i am checking min max values, no need to check for added row Amount

@objc func buttonClicked(sender: UIButton) {
if self.finalSearchValue.isEmpty{
    AlertFun.ShowAlert(title: "", message: "Please enter \(self.alertParam!)", in: self)
}
if self.textCount ?? 0 <= self.alertMinL ?? 0{
    AlertFun.ShowAlert(title: "", message: "\(self.alertParam!) not lessthen \(self.alertMinL!)", in: self)
}
else if self.textCount ?? 0 >= self.alertMaxL ?? 0{
    AlertFun.ShowAlert(title: "", message: "\(self.alertParam!) not graterthen \(self.alertMaxL!)", in: self)
}
else{
    billerFetchService()
}
}

Aucun commentaire:

Enregistrer un commentaire