1
我的應用程序正在被Apple拒絕。它在ADHOC的構建中工作得很好,但是當Apple進行測試時會崩潰。任何幫助將不勝感激。Swift - 應用程序商店拒絕 - 部分申請轉發人爲reabstraction thunk helper
錯誤即時得到是(崩潰日誌):
12 nFocus Admin 0x100057f0c nFocus_Admin.DescriptionViewController.(sendUpdate (nFocus_Admin.DescriptionViewController) ->() ->()).(closure #1) (DescriptionViewController.swift:109)
13 nFocus Admin 0x100056bd8 partial apply forwarder for reabstraction thunk helper from @callee_owned (@in (ObjectiveC.NSData!, ObjectiveC.NSURLResponse!, ObjectiveC.NSError!)) -> (@out()) to @callee_owned (@owned ObjectiveC.NSData!, @owned ObjectiveC.NSURLResponse!, @owned ObjectiveC.NSError!) -> (@unowned()) (DescriptionViewController.swift:0)
我的代碼 -
func sendUpdate(){
//Activity Indicator
activityIndicator = UIActivityIndicatorView (frame: CGRectMake (0, 0, 50, 50))
activityIndicator.center = self.view.center
activityIndicator.hidesWhenStopped = true
activityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray
view.addSubview(activityIndicator)
activityIndicator.startAnimating()
UIApplication.sharedApplication().beginIgnoringInteractionEvents()
//Make request to server
var request = NSMutableURLRequest(URL: NSURL(string: "http://******(actual site value hidden)/sendUpdate.php")!)
request.HTTPMethod = "POST"
var todaysDate:NSDate = NSDate()
var dateFormatter:NSDateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "MMMM dd, yyyy"
var date:String = dateFormatter.stringFromDate(todaysDate)
println(date)
dateFormatter.dateFormat = "h:mm a"
var time:String = dateFormatter.stringFromDate(todaysDate)
println("The time is \(time)")
let id = NSUserDefaults.standardUserDefaults().objectForKey("id") as! String!
println(id)
let postString = "adminId=\(id)&date=\(date)&time=\(time)&site1=\(siteDescriptions[0])&site2=\(siteDescriptions[1])&site3=\(siteDescriptions[2])&site4=\(siteDescriptions[3])&site5=\(siteDescriptions[4])&site6=\(siteDescriptions[5])&site7=\(siteDescriptions[6])&site8=\(siteDescriptions[7])&site9=\(siteDescriptions[8])&site10=\(siteDescriptions[9])&site11=\(siteDescriptions[10])&site12=\(siteDescriptions[11])&site13=\(siteDescriptions[12])&site14=\(siteDescriptions[13])&site15=\(siteDescriptions[14])&site16=\(siteDescriptions[15])&site17=\(siteDescriptions[16])&site18=\(siteDescriptions[17])&site19=\(siteDescriptions[18])&site20=\(siteDescriptions[19])&site21=\(siteDescriptions[20])&site22=\(siteDescriptions[21])&site23=\(siteDescriptions[22])&site24=&site25="
println("\(postString)")
request.HTTPBody = postString.dataUsingEncoding(NSUTF8StringEncoding)
let task = NSURLSession.sharedSession().dataTaskWithRequest(request) {
data, response, error in
dispatch_sync(dispatch_get_main_queue()){
self.activityIndicator.stopAnimating()
UIApplication.sharedApplication().endIgnoringInteractionEvents()
}
if error != nil {
println("error=\(error)")
let alert = UIAlertController(title: "Alert", message: "Please check your internet connection", preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "Ok", style: .Cancel, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
return
}
var err: NSError?
var json = NSJSONSerialization.JSONObjectWithData(data, options: .MutableContainers, error: &err) as? NSDictionary
// Did the JSONObjectWithData constructor return an error? If so, log the error to the console
if(err != nil) {
println(err!.localizedDescription)
let jsonStr = NSString(data: data, encoding: NSUTF8StringEncoding)
println("Error could not parse JSON: '\(jsonStr)'")
let alert = UIAlertController(title: "Alert", message: "Something went wrong. Please try again later.", preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "Ok", style: .Cancel, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
}
else{
if(json!["status"] as! String == "success"){
//Message went successfully
let alert = UIAlertController(title: "Success", message: "Updates sent successfully", preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "OK", style: .Cancel, handler: {
action in
self.performSegueWithIdentifier("backToList", sender: self)
// siteDescriptions = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]
// self.listTableView.reloadData()
}))
self.presentViewController(alert, animated: true, completion: nil)
}else{
var message = json!["message"] as! String!
let alert = UIAlertController(title: "Alert", message: message, preferredStyle: .Alert)
alert.addAction(UIAlertAction(title: "Ok", style: .Cancel, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
}
}
}
task.resume()
}
在下面的代碼片段的最後一行是一行109 -
alert.addAction(UIAlertAction(title: "OK", style: .Cancel, handler: {
action in
self.performSegueWithIdentifier("backToList", sender: self)
// siteDescriptions = ["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]
// self.listTableView.reloadData()
}))
self.presentViewController(alert, animated: true, completion: nil)