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
How to Add a Show More/Show Less Uibutton to Control Uitextview
Sharing Highscore with Social Media
Xcode 7 Run on MAC Osx 10.10 Yosemite
Is There an Kotlin Equivalent 'With' Function in Swift
Xcode Playgrounds Shared Directory Not Working
Selectively Remove and Delete Objects from a Nsmutablearray in Swift
In Which Cases Arscnview.Raycastquery Returns Nil
Swift 2 Error Handling and While
How to Change Its Own Button Image on Tap in Swift
Saving Coredata to a Web Server with Swift 3.0
Play Mp4 Using Mpmovieplayercontroller() in Swift
Attrackingmanager Stopped Working in iOS 15
Swift 3: Safe Way to Decode Values with Nscoder
Showing Notification Banner on MAC with Swift
Array Extension Called from Other Module
How to Hide the Back Button from the Status Bar on the Apple Watch