xcode 错误“线程 1:断点 2.1”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32038226/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 07:40:50  来源:igfitidea点击:

Error "Thread 1: breakpoint 2.1"

xcodeswift

提问by Creative crypter

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.

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

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"]

        }
    }
}

The line I commented prints:

我评论的那一行打印:

Thread 1: breakpoint 2.1

线程 1:断点 2.1

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

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

回答by Eric Aya

You may have accidentally set a breakpoint without noticing.

您可能在没有注意到的情况下意外设置了断点。

enter image description here

在此处输入图片说明

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

单击并拖动表示装订线外断点的蓝色勾号以将其擦除。