UIRefreshControl:发送到实例的无法识别的选择器 - absoluteURL

UIRefreshControl: unrecognized selector sent to instance - absoluteURL

在我开始之前,我已经解决了与这个问题相关的每一个问题。没有帮助。

我想刷新从网站获取的 tableView 的 json 内容。

每个类别的 URL 来自不同的文件,其中列出了所有类别。

获取内容的代码是这样的

func animalSelected(animal: Animal) {

var request: NSURLRequest = NSURLRequest(URL: animal.url!)

   self.refresh(animal.url!)
    let session = NSURLSession.sharedSession()
    let task = session.dataTaskWithURL(animal.url!, completionHandler: {data, response, error -> Void in
        //   println("Task completed")
        if(error != nil) {
            // If there is an error in the web request, print it to the console
            println(error.localizedDescription)
        }
        var err: NSError?

        var jsonResult = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: &err) as NSDictionary
        if(err != nil) {
            // If there is an error parsing JSON, print it to the console
            println("JSON Error \(err!.localizedDescription)")
        }
        let results: NSArray = jsonResult["posts"] as NSArray
        self.didReceiveResults(jsonResult)

    })
    task.resume()

    delegate?.collapseSidePanels?()

}

func didReceiveResults(results: NSDictionary) {
    var resultsArr: NSArray = results["posts"] as NSArray
    dispatch_async(dispatch_get_main_queue(), {
        self.tableData = resultsArr
        self.tableView.reloadData()
    })
}

我的ViewDidLoad方法和refresh方法如下图

override func viewDidLoad() {
    super.viewDidLoad()
            refresher = UIRefreshControl()
            refresher.attributedTitle = NSAttributedString(string: "Pull to Refresh")
            refresher!.addTarget(self, action: "refresh:", forControlEvents: UIControlEvents.ValueChanged)

            self.tableView.addSubview(refresher)
}

func refresh(categoryUrl : NSURL) {

    var request: NSURLRequest = NSURLRequest(URL: categoryUrl)

   let session = NSURLSession.sharedSession()
    let task = session.dataTaskWithURL(categoryUrl, completionHandler: {data, response, error -> Void in
        if(error != nil) {
            // If there is an error in the web request, print it to the console
            println(error.localizedDescription)
        }
        var err: NSError?

        var jsonResult = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: &err) as NSDictionary
        if(err != nil) {
            // If there is an error parsing JSON, print it to the console
            println("JSON Error \(err!.localizedDescription)")
        }
        let results: NSArray = jsonResult["posts"] as NSArray
        self.didReceiveResults(jsonResult)

    })
    task.resume()
    self.refresher.endRefreshing()

           }

我需要刷新已选择的相同 URL 的内容,即刷新相同的类别。

我收到此错误:[UIRefreshControl absoluteURL]: unrecognized selector sent to instance 0x7fa0b3d73750

我认为这与absoluteURL有关。 bt不知道是什么..

plsss plssssss plssss 帮助

您正在尝试获取您认为实际上是 NSURLUIRefreshControlabsoluteURL

确切地说,您在 refresh(categoryUrl: NSURL) 中的发件人是 UIRefreshControl 而不是 NSURL