Swift, Error Exc_Breakpoint (Code=1, Subcode=0X100695474)

Swift, error EXC_BREAKPOINT (code=1, subcode=0x100695474)

Check your IBOutlets and if they are linked to your storyboard.

EXC_BREAKPOINT (code=1, subcode=0x1051fbb50) console prints this: fatal error: Index out of range

the issue was that the signInSegue was out side the credential function like this:

func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!) {
if error != nil {
print(error)
return
}
print("Successfully logged in with Facebook...")
let credential = FacebookAuthProvider.credential(withAccessToken: FBSDKAccessToken.current().tokenString)
Auth.auth().signIn(with: credential) { (user, error) in
print("User logged in...")

}
self.performSegue(withIdentifier: "signInSegue", sender: nil)
}

it should be like this:

func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!) {
if error != nil {
print(error)
return
}
print("Successfully logged in with Facebook...")
let credential = FacebookAuthProvider.credential(withAccessToken: FBSDKAccessToken.current().tokenString)
Auth.auth().signIn(with: credential) { (user, error) in
print("User logged in...")
self.performSegue(withIdentifier: "signInSegue", sender: nil)

}

}

How do you parse JSON in Swift when you continue to get an EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0) error?

Trying a more traditional approach when parsing, I attempted to use:

//Set up the network request, asynchronously
let urlPath: String = "https://api.github.com/users/" + userName
var url: NSURL = NSURL(string: urlPath)
var request: NSURLRequest = NSURLRequest(URL: url)
let queue:NSOperationQueue = NSOperationQueue()

//Make the asynchronous request
NSURLConnection.sendAsynchronousRequest(request, queue: queue, completionHandler:{ (response: NSURLResponse!, data: NSData!, error: NSError!) -> Void in

var err: NSError

//Store the JSON data from the Github api
var jsonResult: NSDictionary = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: nil) as NSDictionary

This gave me an EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0) error

So, I tried another parsing method

var url: NSURL = NSURL(string: urlString)
var request: NSURLRequest = NSURLRequest(URL: url)
let queue: NSOperationQueue = NSOperationQueue()

//Store the JSON data from the Github api
var jsonResult: NSData = NSData(contentsOfURL: url)

var error:NSError?

// Retrieve Data
var JSONData = NSData.dataWithContentsOfURL(url, options: NSDataReadingOptions(), error: &error)
// Create another error optional
var jsonerror:NSError?
// We don't know the type of object we'll receive back so use AnyObject
let swiftObject:AnyObject = NSJSONSerialization.JSONObjectWithData(JSONData, options: NSJSONReadingOptions.AllowFragments, error:&jsonerror)!
// JSONObjectWithData returns AnyObject so the first thing to do is to downcast this to a known type
if let nsDictionaryObject = swiftObject as? NSDictionary {
if let swiftDictionary = nsDictionaryObject as Dictionary? {
println(swiftDictionary)
}
}
else if let nsArrayObject = swiftObject as? NSArray {
if let swiftArray = nsArrayObject as Array? {
println(swiftArray)
}
}

This method allowed me to parse the information



Related Topics



Leave a reply



Submit