Xcode: how to fix Thread 5: EXC_BREAKPOINT (code=1, subcode=0x10025c76c)

吃可爱长大的小学妹 提交于 2019-12-29 09:12:35

问题


when I click the btnLogin in the iPhone the xCode was displayed the error:

Thread 5: EXC_BREAKPOINT (code=1, subcode=0x10025c76c)

this is my code

@IBOutlet weak var abc: UILabel!

   ...

@IBAction func btnLogin(sender: UIButton) {

    var jsonResult = AnyObject?()

    let urlAsString = "lifewinner2015.dlinkddns.com/SERVER/user?function=login&username=Shing&password=123456789"

    let url = NSURL(string: urlAsString)

    let urlSession = NSURLSession.sharedSession()

    let jsonQuery = urlSession.dataTaskWithURL(url!, completionHandler: {data, reponse, error -> Void in
        if (error != nil) {
            print("error")
        }

        do {
            jsonResult = try NSJSONSerialization.JSONObjectWithData(data!, options: .AllowFragments) as! NSDictionary
            let jsonAbc: String! = jsonResult!["return"] as! String

            dispatch_async(dispatch_get_main_queue(), {
                self.abc.text = jsonAbc
            })
        } catch let err as NSError! {
            if (err != nil) {
                print("JSON Error")
            }
        }
    })
    jsonQuery.resume()

}
  1. run the app on the iPhone (9.2 Version)
  2. click the Login button
  3. Xcode will display the error(Photo 1)

    Photo 1:

please help me to fix this error please.


but I am not to add the breakpoint to the line number


回答1:


I think thats not an error ... its breakpoint .. just remove it or continue program execution like below

or for remove breakpoints just drag and remove it from show breakpoint navigator

one more thing don't make force unwrap.. use if let to unwrap like

if let jsonAbc = jsonResult!["return"] as? String{
       dispatch_async(dispatch_get_main_queue(), {
            self.abc.text = jsonAbc
        })
}  

one more possibility is added in this answer that "Take a look at the Window in Interface Builder and try to temporary remove all reference to any IBOutlet present in the View Controller"




回答2:


You added a breakpoint in xcode, probably without noticing. Go the file, right click on the line number where you breakpoint is, and select "delete breakpoint"




回答3:


have you deleted button?

if yes then you may want to check the outlet of button..

just right click on button in story board and find in property inspector if there are two or more action or outlet performed on button.

If there are two action ..one you are currently using and another which was added previously and you have removed from your.swift file you must delete the referring outlet from the button too just keep in mind..



来源:https://stackoverflow.com/questions/35860313/xcode-how-to-fix-thread-5-exc-breakpoint-code-1-subcode-0x10025c76c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!