错误“线程 1:断点 2.1";

Error quot;Thread 1: breakpoint 2.1quot;(错误“线程 1:断点 2.1;)

本文介绍了错误“线程 1:断点 2.1";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 REST API 管理器.它给出了一个错误,我无法修复它.我得到的错误如下突出显示.

I am working on a REST API Manager. It is giving an error and I am not able to fix it. The error I got is given below as highlighted.

import Foundation
import Alamofire
import SwiftyJSON

class RestApiManager {

    var resources: JSON = [

        "resources": [

            "resourceA": []

        ]

    ]

    let apiUrl: String
    let apiUsername: String
    let apiPassword: String

    init(apiUrl: String, apiUsername: String, apiPassword: String) {

        self.apiUrl = apiUrl
        self.apiUsername = apiUsername
        self.apiPassword = apiPassword

        getApiResourceA() { responseObject, error in

            let resourceA = JSON(responseObject!)

            self.resources["resources"]["resourceA"] = resourceA

        }

    }

    func collectDataFromApi(completionHandler: (responseObject: NSDictionary?, error: NSError?) -> ()) {

        prepareHttpRequest(completionHandler)

    }

    func prepareHttpRequest(completionHandler: (responseObject: NSDictionary?, error: NSError?) -> ()) {

        let alamofireRequest = Alamofire.request(.GET, "(self.apiUrl)")

        alamofireRequest.authenticate(user: self.apiUsername, password: self.apiPassword)

        alamofireRequest.responseJSON { request, response, responseObject, error in

            completionHandler(responseObject: responseObject as? NSDictionary, error: error)

        }

    }

    func getAllResources() -> JSON {

        return self.resources

    }

    func getApiResourceA(completion: (responseObject: NSDictionary?, error: NSError?) -> ()) {

        collectDataFromApi() { responseObject, error in

            completion(responseObject: responseObject, error: error)

        }

    }

}

当我调用这个类来获取资源时:

And when I call this class to get the resources:

override func viewDidLoad() {
    super.viewDidLoad()

    if record != nil {
        let url = record?.url
        let username = record?.username
        let password = record?.password

        let restApiManager = RestApiManager(apiUrl: url!, apiUsername: username!, apiPassword: password!) // This line seems buggy

        let delay = 10.0 * Double(NSEC_PER_SEC)
        let time = dispatch_time(DISPATCH_TIME_NOW, Int64(delay))
        dispatch_after(time, dispatch_get_main_queue()) {

            let Resources = restApiManager.getAllResources()

            let ResourceA = Resources["resources"]["resourceA"]

        }
    }
}

我注释的行打印:

线程 1:断点 2.1

Thread 1: breakpoint 2.1

我需要修复该错误的建议.任何建议都非常感谢

I need suggestions for fix that error. Any suggestions are very much appreciated

推荐答案

你可能不小心设置了断点.

You may have accidentally set a breakpoint without noticing.

单击并拖动代表断点的蓝色刻度线将其擦除.

Click and drag the blue tick representing the breakpoint outside of the gutter to erase it.

这篇关于错误“线程 1:断点 2.1";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:错误“线程 1:断点 2.1";