jeudi 27 juin 2019

How to write if condition with using label text (Int) values

I am getting the dates from the server (response) and that values I an storing in an labels and I want to write a if condition using the labels I want to allow to next Viewcontroller if the used leaves should be greater that total leaves and I am getting error my code is

 if  ((self.totalLeaves.text) > (self.usedLeavesLbl.text)) {
            let alert = UIAlertController(title: "Alert", message: "You Dont have leaves to Apply", preferredStyle: .alert)
            alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
                switch action.style{
                case .default:
                    print("Please Enter Details")

                case .cancel:
                    print("cancel")

                case .destructive:
                    print("destructive")
                }}))
            self.present(alert, animated: true, completion: nil)
        }
     else {
        // Fallback on earlier versions
        let secondViewController = self.storyboard?.instantiateViewController(withIdentifier: "ApplyLeavesViewController") as! ApplyLeavesViewController
        self.navigationController?.pushViewController(secondViewController, animated: true)
    }

my error is compile error Cannot convert value of type 'String?' to expected argument type 'UIContentSizeCategory' Construct 'UIContentSizeCategory' from unwrapped 'String' value

Aucun commentaire:

Enregistrer un commentaire