Swift - App store reject - 部分应用转发器用于reabstraction thunk helper

时间:2015-09-05 08:46:05

标签: ios swift thunk

我的应用程序被Apple拒绝了。它可以在ADHOC构建时完美运行,但在Apple进行测试时会崩溃。任何帮助将不胜感激。

我得到的错误是(崩溃日志):

 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)

1 个答案:

答案 0 :(得分:0)

由于无法解决这个问题,我向苹果审核小组求助。不久之后,他们批准了该应用程序,现在它已经在应用程序商店中运行。

希望这有助于其他人。