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

前端之家收集整理的这篇文章主要介绍了xcode – 错误“线程1:断点2.1”前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在研究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)

        }

    }

}

当我打电话给这个班级获取资源时:

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

        }
    }
}

评论的线打印:

Thread 1: breakpoint 2.1

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

解决方法

您可能在不注意的情况下意外设置了断点.

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

猜你在找的iOS相关文章