1

I keep receiving this error, CFNetwork SSLHandshake failed (-9807), in the debug window and have no data displayed when trying to populate a UITableViewController with Firebase data. I have tried this potential solution iOS 9 ATS and Firebase REST but still have the issue.

The code I am using is (Credit to @DavidEast)

class TableViewController1: UITableViewController {
// your firebase reference as a property
var ref: Firebase!
// your data source, you can replace this with your own model if you wish
var items = [FDataSnapshot]()

override func viewDidLoad() {
    super.viewDidLoad()
    // initialize the ref in viewDidLoad
    ref = Firebase(url:"https://the-lighthouse-app.firebase.io/states")
}

override func viewDidAppear(animated: Bool) {
    super.viewDidAppear(animated)
    // listen for update with the .Value event
    ref.observeEventType(.Value) { (snapshot: FDataSnapshot!) in

        var newItems = [FDataSnapshot]()

        // loop through the children and append them to the new array
        for item in snapshot.children {
            newItems.append(item as! FDataSnapshot)
        }

        // replace the old array
        self.items = newItems
        // reload the UITableView
        self.tableView.reloadData()
    }
} 
}
Community
  • 1
  • 1
Will Jackson
  • 335
  • 1
  • 4
  • 8
  • Can you write any data to/from Firebase at all? If not, have you created a project from scratch using the [Firebase QuickStart Guide](https://www.firebase.com/docs/ios/quickstart.html) and see if a new app can read/write data? – Jay Dec 13 '15 at 13:53
  • I just tested it and I can read and write data perfectly @Jay . – Will Jackson Dec 13 '15 at 14:42
  • Great! That means you have connectivity with Firebase so that project is set up correctly. The issue going to be within your code and may not directly be Firebase. I would suggest expanding that app; add a simple tableViewController with a single column tableView and populate it from Firebase. If it throws the same error, put some breakpoints in and nail down what section of code is throwing the error. Then update your question with that code (keep it short!). – Jay Dec 13 '15 at 15:06
  • @Jay I put the code in my question. The problem doesn't appear to be in the code though since the error is popping up in the debug window. – Will Jackson Dec 13 '15 at 15:23
  • Which line is triggering the error? – Jay Dec 13 '15 at 15:33
  • 1
    Modify your observe code thusly: ref.observeEventType(.Value, withBlock: { snapshot in – Jay Dec 13 '15 at 15:41
  • @Jay I Tried modifying the code and the error still showed up. `2015-12-13 12:37:32.334 The Lighthouse App Test[7173:318971] CFNetwork SSLHandshake failed (-9807)` – Will Jackson Dec 13 '15 at 17:38
  • So 2 questions: 1) Is the error occurring in the test App you created that reads and writes data correctly? 2) What line is triggering the error. – Jay Dec 13 '15 at 18:54
  • @Jay I created two separate test apps. I believe I've tested the data population in both the one that can read/write and the one that can't. I apologize for asking such a basic question, but how do you find the line number? – Will Jackson Dec 13 '15 at 19:05
  • @Jay I might have told you the wrong thing. The error is appearing in the application log at the bottom of the screen – Will Jackson Dec 13 '15 at 19:36
  • Put a few breakpoints in your code and step through them until you see the error. That's the line of code we want to look at. – Jay Dec 14 '15 at 19:03
  • @Jay I've put the breakpoints in, but I can't seem to find the error in the debug window. By clicking on "Main", I can only see my `AppDelegate` file and not my swift file that I have for the `TableViewController`. – Will Jackson Dec 15 '15 at 00:41
  • When you put breakpoints in your code, it will stop the compiler totally an enable you to walk through your code line by line. You really need to understand XCode and how that process works as it's critical for debugging. I would put a breakpoint here var ref: Firebase! in the code you pasted above and then run your code. It will stop on that line and you can then walk through the rest of that method one line at a time until the error occurs. – Jay Dec 15 '15 at 18:54
  • @Jay I've found my code but which button do you use: step over, step in, or step out? – Will Jackson Dec 16 '15 at 01:19
  • Please refer to the Xcode documentation in depth information about how to use the debugger. Step over executes the code at that line and moves to the next line. Step in steps into the sub-code called by the line and step out steps back out to the main calling function. In general step over until you fine the line the throws the error. Once you know that you may need to re-run the code and step into. [XCode Debugging](https://developer.apple.com/library/tvos/documentation/ToolsLanguages/Conceptual/Xcode_Overview/UsingtheDebugger.html#//apple_ref/doc/uid/TP40010215-CH57-SW1) – Jay Dec 16 '15 at 15:59

0 Answers0