我得到了这个错误objc [17272]:类PLBuildVersion在两者中实现

时间:2016-10-30 17:26:34

标签: swift nsurlsession

这是我要将数据发布到我的网站页面的代码,但我得到了错误

  

objc [17272]:类PLBuildVersion在两者中实现   /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices   (0x1193af998)和   /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices   (0x1191d4d38)。将使用两者之一。哪一个未定义。   错误   /BuildRoot/Library/Caches/com.apple.xbs/Sources/VectorKit_Sim/VectorKit-1230.31.8.23.3/GeoGL/GeoGL/GLCoreContext.cpp   1763:InfoLog SolidRibbonShader:错误   /BuildRoot/Library/Caches/com.apple.xbs/Sources/VectorKit_Sim/VectorKit-1230.31.8.23.3/GeoGL/GeoGL/GLCoreContext.cpp   1764:警告:未读取顶点着色器'v_gradient'的输出   片段着色器

func senddata(_ submit:String, username:String,password:String, email:String, jobtype:String, pay:String){


        let myUrl = URL(string: "http://localhost/halloffame/php/senddata.php");
        let request = NSMutableURLRequest(url:myUrl!);
        request.httpMethod = "POST";

        let postString = "submit=\(submit)&jobtype=\(jobtype)&pay=\(pay)";

        request.httpBody = postString.data(using: String.Encoding.utf8);

        let task = URLSession.shared.dataTask(with: request as URLRequest, completionHandler: { (data:Data?, response:URLResponse?, error:NSError?) -> Void in
            DispatchQueue.main.async
            {

                // if there is an error throw an alert message
                if(error != nil)
                {
                    //Display an alert message
                    let myAlert = UIAlertController(title: "Alert", message: "something wrong", preferredStyle: UIAlertControllerStyle.alert);
                    let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler:nil)
                    myAlert.addAction(okAction);
                    self.present(myAlert, animated: true, completion: nil)
                    return
                }
                // get feedback from the website
                do {
                    let json = try JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as? NSDictionary
                    if let parseJSON = json {
                        // if status is 200
                        let status = parseJSON["status"] as? String
                        if(status! == "200")
                        {
                            // show the result of the data
                            let status = parseJSON["status"]
                        }else {
                            // display an alert message
                            let myAlert = UIAlertController(title: "Alert", message: status, preferredStyle: UIAlertControllerStyle.alert);
                            let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler:nil)
                            myAlert.addAction(okAction);
                            self.present(myAlert, animated: true, completion: nil)
                        }

                    } // end of parseJSON
                } catch
                {
                    print(error)
                }
            }// dispatch
            } as! (Data?, URLResponse?, Error?) -> Void).resume() // nsurlsession

源代码是代码的最后一行,我试图将该行删除为! (Data?, URLResponse?, Error?) -> Void)但是XCODE给了我错误并建议再次添加它。如果我用代码构建一个模拟器,它显示没有问题,直到我调用该函数,然后它冻结并给了我这个错误。这不会发生在swift 2中,但只有在升级后才会发生。

2 个答案:

答案 0 :(得分:0)

我在iPhone应用程序中遇到了类似的错误。重置iOS模拟器为我修复了它。模拟器 - >重置内容和设置。

答案 1 :(得分:-1)

我找到了解决方案:

in

   let task = URLSession.shared.dataTask(with: request as URLRequest, completionHandler: { (data:Data?, response:URLResponse?, error:NSError?) -> Void in
            DispatchQueue.main.async

我将其改为

let task = URLSession.shared.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
            DispatchQueue.main.async

然后我删除底部的数据,响应,错误 从这个

 } as! (Data?, URLResponse?, Error?) -> Void).resume() // nsurlsession

进入这个

 }).resume() // nsurlsession