ios - Facing error as invalid literal for int () with base 10: in swift 2 -


enter image description here

as per screenshot while submitting feedback facing issue. appreciated.

i have enter comments smile or sad after typing text ride. working fine. while clicking on submit button getting journeyid nil other in self.journeyapidetails getting whole data json. in advance.

 func submitbuttontapped() {              if self.smileactive! == true || self.frownactive!  == true {                  let comment = (self.mainview.textfield.text! == "tap type" || self.mainview.textfield.text! == "leave additional comments here") ? "": self.mainview.textfield.text!                  let rating = self.smileactive! == true ? "true":"false"                  let journeyid = self.journeyapidetails!["data"]["journey_id"].stringvalue                 let userid = accountservice.sharedinstance.typeofuser() == .customer ? self.journeydetails?.driver.id : self.journeydetails?.customer.id                   let details = ["rating":rating, "comment":comment, "journey_id":journeyid]                  journeyservice().rateauser(details).onsuccess { (json) -> void in                      if json["status"].stringvalue == "success" {                         print("dismissviewcontrolleranimate")                         self.dismissviewcontrolleranimated(true, completion: nil)                         accountservice.sharedinstance.clearjourneycontent()                       } else if json["status"].stringvalue == "fail" {                          print("dismissviewcontrolleranimated")                          self.displayalert("error", message: json["message"].stringvalue)                     }                 }             }              else {                 super.displayalert("feedback", message: "give feedback , optionally add comments.")             }         }     } 

invalid literal int () base 10: '' error message python indicating want convert empty string integer. means server expects string contains decimal digits, give empty string instead. points details having wrong input, in particular journeyid field.

after discussing op, find out problem in self.journeyapidetails!["data"]: array containing single object, op didn't notice it. solution change line to:

let journeyid = self.journeyapidetails!["data"][0]["journey_id"].stringvalue //                                             ^^^ 

moral of story: careful analyze structure of json send , receive.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -