ios - Swift 3 app runs on simulator crashes on device -


i use alamofire library requests. when run app on simulator works fine, when run on real device crashes.

the following code makes app crashes:

downloadsubviewcolumn(selectedmaster: selectedmaster,subviewnumber: subviewnumber){(value) -> void in             if !value.isempty{                 let seperatedcolumn = value.components(separatedby: "^")                 var paramsstring = ""                 in seperatedcolumn {                     paramsstring.append(";\(i)~\(self.dataarray[indexpath.row][int(i)!])")                 }                 paramsstring.remove(at: paramsstring.startindex)                 self.downloadsubviewdata(selectedmaster: self.selectedmaster , params:paramsstring ,subviewnumber: self.subviewnumber){(value) -> void in                     if !value.isempty{                         self.headerarray.removeall()                         self.dataarray.removeall()                         self.tableviewdetail.reloaddata()                         let arrayseperatedbyspace = value.components(separatedby: "\r")                         let arrayseperatedbypercent = arrayseperatedbyspace.filter({$0.characters.first == "%"})                         self.footersettings = arrayseperatedbypercent[0].replacingoccurrences(of: "%", with: "")                         self.headerarray = self.setheader(arrayseperatedbyspace: arrayseperatedbyspace)                         self.dataarray = self.setdata(arrayseperatedbyspace: arrayseperatedbyspace , headerarray: self.headerarray)                          self.settablewidth()                         self.tableviewdetail.reloaddata()                         self.subviewnumber += 1                       }else{                         self.alert(message: "veri bulunamadı.", title: "title")                     }                 }             }else{                 self.alert(message: "altveri bulunamadı.", title: "title")             } } 

here downloadsubviewcolumn():

func downloadsubviewcolumn(selectedmaster : string,subviewnumber : int ,subdatacompletionhandler : @escaping completionhandler){  var subviewnumberstring = ""     if subviewnumber < 10{         subviewnumberstring = "00\(subviewnumber)"     }     dispatchqueue.global(qos: .background).async {         let url = "my_url".replacingoccurrences(of: " ", with: "%20")         alamofire.request(url).responsestring(completionhandler: { response in             switch response.result{             case .failure(_):                 subdatacompletionhandler("")                 swiftspinner.hide()             case .success(_):                 guard let tempdata = response.data , let detailresponse = string(data: tempdata, encoding: .utf8) else {                     return                 }                 if !detailresponse.isempty{                     subdatacompletionhandler(detailresponse)                     swiftspinner.hide()                  }else{                     subdatacompletionhandler("")                     swiftspinner.hide()                 }             }         })         // go main thread update ui         dispatchqueue.main.async {           } } } 

and here downloadsubviewdata():

func downloadsubviewdata(selectedmaster : string ,params : string , subviewnumber : int,subdatacompletionhandler : @escaping completionhandler){     dispatchqueue.global(qos: .background).async {         var subviewstring = ""         if subviewnumber < 10{             subviewstring = "00\(subviewnumber)"         }else{             subviewstring = "0\(subviewnumber)"         }         let url = "my_url2".replacingoccurrences(of: " ", with: "%20")         print(url)         alamofire.request(url).responsestring(completionhandler: { response in             switch response.result{             case .failure(_):                 subdatacompletionhandler("")                 swiftspinner.hide()             case .success(_):                 guard let tempdata = response.data , let detailresponse = string(data: tempdata, encoding: .utf8) else {                     return                 }                 print(detailresponse)                 if !detailresponse.isempty{                     subdatacompletionhandler(detailresponse)                     swiftspinner.hide()                  }else{                     subdatacompletionhandler("")                     swiftspinner.hide()                 }             }         })         // go main thread update ui         dispatchqueue.main.async {           }     }  } 


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -