Reputation: 111
In my iOS app, I have a log in Button
to go from one viewController
to another, which uses the following function:
@IBAction func logInButton(sender: AnyObject) {
if loggedIn == true {
// user is signed in
print("A user is logged in.")
uid = user.uid
self.currentUser(uid)
self.performSegueWithIdentifier("logIn", sender: sender)
} else {
print("No current user.")
let anim = CAKeyframeAnimation( keyPath:"transform" )
anim.values = [
NSValue( CATransform3D:CATransform3DMakeTranslation(-10, 0, 0 ) ),
NSValue( CATransform3D:CATransform3DMakeTranslation( 10, 0, 0 ) )
]
anim.autoreverses = true
anim.repeatCount = 2
anim.duration = 7/100
self.passwordTextField.layer.addAnimation( anim, forKey:nil )
self.welcomeTextLabel.hidden = false
self.welcomeTextLabel.text = "Please sign in first"
}
}
There's a function which runs within viewDidLoad()
that updates the loggedIn
value. I've tested this function when loggedIn == false
(based on console output), and the app crashes based on code that executes on the subsequent viewController
. I know why it crashes (no user data) but I don't know why the segue is being performed at all.
If you need more code to diagnose please ask.
Upvotes: 1
Views: 53
Reputation: 72410
In your storyboard you need to create the segue between two view controllers instead of button to DestinationViewController.
Please remove that segue and create one segue from your LoginViewController to your DestinationViewController.
Upvotes: 4