正在获取错误错误域= NSCocoaErrorDomain代码= 3840“无值。”运行请求时,UserInfo = {NSDebugDescription =无值。} httpMethod =“ GET”

时间:2019-10-09 06:52:48

标签: ios json http swift4

登录后,我正在运行我的功能之一,以使用访问令牌从服务器获取通知,在 request.httpMethod =“ GET” 行出现错误。我是Swift的初学者,可以帮助一些人修改代码以摆脱错误。让我知道您是否需要更多详细信息。基本上,此功能将访问令牌传递给服务器,并从服务器获取用户的相关通知。下面我粘贴了我的代码

详细错误

  

2019-10-09 12:07:09.697306 + 0530 facitech_newfile [58366:1505543]   [Common] _BSMachError:端口9707; (os / kern)无效功能(0x14)   “无法插入COPY_SEND”(lldb)错误域= NSCocoaErrorDomain   代码= 3840“无值”。 UserInfo = {NSDebugDescription =无值。}

func load_notification()
     {
        let Detail = self.storyboard?.instantiateViewController(withIdentifier: "Detail") as! 
        DetailViewController
        let appdelegatenew = UIApplication.shared.delegate
        appdelegatenew?.window??.rootViewController = Detail

       let accesstoken: String? = KeychainWrapper.standard.string(forKey: "tokennew")
        print(accesstoken)
       let myUrl = URL(string:"https://communitymgmtapi.azurewebsites.net/api/notification/")
       var request = URLRequest(url:myUrl!)
         print(accesstoken)
        request.httpMethod = "GET" //compose Query Sgtring
        request.addValue("Bearer \(accesstoken!)", forHTTPHeaderField: "Authorization")
        let task = URLSession.shared.dataTask(with: request) {(data: Data?,response:URLResponse?,error:Error?) in
            do {
                let json = try JSONSerialization.jsonObject(with: data!, options:.mutableContainers) as? NSDictionary
                if let parseJSON = json {
                    DispatchQueue.main.async {
                        let subj = parseJSON["subject"] as? String
                        let msg = parseJSON["body"] as? String
                        print(subj)
                        print(msg)
                    }

                }
            }
            catch{
                print(error)
            }



        }
        task.resume()
    }

0 个答案:

没有答案