0

我的代码在 swift 2.0 中运行,但是当我在 swift 2.1 上更新代码时,它的返回错误“调用可以抛出但未标有尝试”请给我解决方案这是我的代码,我已将这一行放在那里,我在行中出现错误“ /****这里是错误****/"

  func connectionGetChannelFeed()
    {
         if IJReachability.isConnectedToNetwork() {
        let url : String = "\(WebServicesUrl.GlobalConstants.SiteUrl)get_favs.php?user_id=\(delegate.appd_userid)&at=0&channels"
        let request : NSMutableURLRequest = NSMutableURLRequest()
        request.URL = NSURL(string: url)
        request.HTTPMethod = "GET"

        NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue(), completionHandler:{ (response:NSURLResponse?, data: NSData?, error: NSError?) -> Void in


            do {

          /****Here is Error****/
                let jsonResult: NSArray! = NSJSONSerialization.JSONObjectWithData(data!, options:NSJSONReadingOptions.MutableContainers) as? NSArray

                self.delegate.ary_channelList = jsonResult;


            } catch {
                // handle error
            }



        })


         }else

         {

            JLToast.makeText("\(WebServicesUrl.MessageConstant.NetworkErrorMEssage)"  ,duration: WebServicesUrl.durationTime.timeDuration).show()



        }


    }
4

1 回答 1

2

尝试添加“尝试”:

let jsonResult: NSArray! = try NSJSONSerialization.JSONObjectWithData(data!, options:NSJSONReadingOptions.MutableContainers) as? NSArray
于 2015-10-12T16:13:47.127 回答