Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

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

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: http://i.stack.imgur.com/loErxm.jpg

please help me to fix this error please.


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

http://i.stack.imgur.com/oT8AY.png

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I think that's not an error ... its breakpoint .. just remove it or continue program execution by tapping the button described in the next picture.

enter image description here

or for remove breakpoints just drag and remove them from the breakpoint navigator

enter image description here

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 temporarily remove all reference to any IBOutlet present in the View Controller"


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...