这个应用程序工作得很好很长一段时间,而且我没有更改任何引用URL,密钥都是正确的等等但现在当我登录或注册新帐户时应用程序崩溃我得到这个错误,我把一个异常断点,但它没有破坏任何地方,立即恢复到线程或主页,所以我不知道什么“子”是一个空字符串。没有我能看到的是。
*** Terminating app due to uncaught exception 'InvalidPathValidation', reason: '(childByAppendingPath:) Must be a non-empty string and not contain '.' '#' '$' '[' or ']''
这是登录和注册代码,它甚至不会在错误块中打印错误,当我放置一个断点时,块内没有任何反应。基础参考是正确的,就像我说昨天工作正常。谢谢你的帮助!
enum ViewMode {
case LogIn
case SignUp
}
var viewMode = ViewMode.SignUp
@IBAction func proceed(sender: AnyObject) {
switch viewMode {
case .LogIn:
let emailString = usernameField.text
let pwString = passwordField.text
if emailString != "" && pwString != "" {
DataService.sharedInstance.BASE_REF.authUser(emailString, password: pwString, withCompletionBlock: { error, authData in
if error != nil {
print(error.localizedDescription)
self.loginErrorAlert("Oops", message: "Something went wrong! Please try again")
} else {
NSUserDefaults.standardUserDefaults().setValue(authData.uid, forKey: uidKey)
self.performSegueWithIdentifier(logInSegue, sender: nil)
}
})
} else {
loginErrorAlert("Oops", message: "Don't forget to enter both an Email and Password")
}
case .SignUp:
//properties for our user
let emailString = emailField.text
let pwString = passwordField.text
let username = usernameField.text
let lastName = lastNameField.text
let firstName = firstNameField.text
if username != "" && emailString != "" && pwString != "" {
DataService.sharedInstance.BASE_REF.createUser(emailString, password: pwString, withValueCompletionBlock: { (error, result) in
if error != nil {
print(error.localizedDescription)
self.loginErrorAlert("Oops", message: "There was an error creating your account, please try again!")
} else {
DataService.sharedInstance.BASE_REF.authUser(emailString, password: pwString, withCompletionBlock: { (error, authData) in
let userDictionary = ["provider" : authData.provider!, "email" : emailString!, "username" : username!, "firstName" : firstName!, "lastName" : lastName!]
DataService.sharedInstance.createNewAccount(authData.uid, user: userDictionary)
})
NSUserDefaults.standardUserDefaults().setValue(result["uid"], forKey: uidKey)
NSUserDefaults.standardUserDefaults().setObject(username, forKey: "usernameString")
self.performSegueWithIdentifier(signUpSegue, sender: self)
}
})
} else {
loginErrorAlert("Oops", message: "Don't forget to enter your email, a username and a password!")
}
}
}