错误“线程1:断点2.1”
我正在使用REST APIpipe理器。 这是一个错误,我无法修复它。 我得到的错误如下所示突出显示。
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) } } }
当我打电话给这个class级来获取资源时:
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
我需要解决这个错误的build议。 任何build议都非常感谢
您可能无意中设置了一个断点而不会注意到。
点击并拖动表示水槽外的断点的蓝色勾号将其抹除。