0

I am getting the error "terminating with uncaught exception of type NSException." This question has a lot of views, but it does not solve my problem: libc++abi.dylib: terminating with uncaught exception of type NSException (lldb) I have been able to track down the location of my error to this function:

func likeToLikeForAll(movieID: Int) {

    let uid  = Auth.auth().currentUser?.uid
    Api.Like.REF_LIKES.child(uid!).child("100000").setValue(true)
    Api.Like.REF_LIKES.child(uid!).observeSingleEvent(of: .value, with: { (snapshot) in
        if let dictionary = snapshot.value as? [String: AnyObject] {
            let array = Array(dictionary.keys)
            for i in array {
                let iInt = Int(i)!
                if iInt != 100000 {
                    if movieID > iInt {
                        let movieIDString = String(movieID)
                        print("Bigger")
                        let nameOfLikeToLike = i + "." + movieIDString + "LL"
                        Api.LikeToLike.REF_LIKETOLIKE.child(nameOfLikeToLike).setValue(1)
                    }
                    else if movieID < iInt {
                        print("Smaller")
                    }
                    else if movieID == iInt {
                        print("Equal")
                    }
                }
                else {
                    print("Extra")
                }
            }
        }
    })
}

Does anybody know how to resolve this error?

ReyAnthonyRenacia
  • 17,219
  • 5
  • 37
  • 56
Bob Samuels
  • 53
  • 10

1 Answers1

1

Your problem is with the line "let nameOfLikeToLike = i + "." + movieIDString + "LL"" You cannot have a . in a String being sent to Firebase realtime database. Consider replacing it with ":"

Bob Samuels
  • 53
  • 10
  • Well done and great catch. See [Struture Database](https://firebase.google.com/docs/database/ios/structure-data) – Jay Aug 14 '18 at 17:16