I am using xcode 7 beta and swift 2.0. I am following a tutorial (youtube.com/watch?v=PKOswUE731c).
In short i have a storyboard with 3 views; a protected vc, a login vc and RegisterViewController. I have set 2 segues
segue modal with protected_vc <-> login_vc identified with loginView
segue modal on a button in login_vc <-> RegisterViewController identified with registerView
I encountered a problem when with a register button on my login vc. If i click the register button it crashes the app and i get the message 'Receiver (<registerLogin.RegisterViewController: 0x7f97235f6140>) has no segue with identifier 'loginView''
Now i notice in the tutorial selecting a segue gives another dropdown, in my case i only see push - modal -popover - replace and custom. Could this be the cause??
Or this part ViewController
override func viewDidAppear(animated: Bool) {
self.performSegueWithIdentifier("loginView", sender: self);
}
Complete code for RegisterViewController is
import UIKit
class RegisterViewController: ViewController {
@IBOutlet weak var userEmailTextField: UITextField!
@IBOutlet weak var userPasswordTextField: UITextField!
@IBOutlet weak var repeatPasswordTextField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func registerButtonTapped(sender: AnyObject) {
let userEmail = userEmailTextField.text
let userPassword = userPasswordTextField.text
let repeatPassword = repeatPasswordTextField.text
//No empty fields
if((userEmail!.isEmpty || userPassword!.isEmpty || repeatPassword!.isEmpty)){
//Display alert message
displayMyAlertMessage("All fields required")
return
}
//Check if passwords match
if(userPassword != repeatPassword){
//Display alert message
displayMyAlertMessage("Passwords mistakes")
return
}
//Store data
NSUserDefaults.standardUserDefaults().setObject(userEmail, forKey: "userEmail")
NSUserDefaults.standardUserDefaults().setObject(userPassword, forKey: "userPassword")
NSUserDefaults.standardUserDefaults().synchronize()
//Display alert message with confirmation
let myAlert = UIAlertController(title: "Alert", message: "Registration successful", preferredStyle: UIAlertControllerStyle.Alert)
let okAction = UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default) { action in
self.dismissViewControllerAnimated(true, completion: nil)
}
}
func displayMyAlertMessage(userMessage:String){
let myAlert = UIAlertController(title: "Alert", message: userMessage, preferredStyle: UIAlertControllerStyle.Alert)
let okAction = UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: nil)
myAlert.addAction(okAction)
self.presentViewController(myAlert, animated: true, completion: nil)
}
}
and the complete error message (manually wrapped first line):
2015-10-11 07:17:57.378 registerLogin[667:10462] *** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: 'Receiver (<registerLogin.RegisterViewController: 0x7fb7f978d4c0>)
has no segue with identifier 'loginView''
*** First throw call stack:
(
0 CoreFoundation 0x0000000102d249b5 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000104923deb objc_exception_throw + 48
2 UIKit 0x00000001036caba3 -[UIViewController shouldPerformSegueWithIdentifier:sender:] + 0
3 registerLogin 0x0000000102b4260f _TFC13registerLogin14ViewController13viewDidAppearfS0_FSbT_ + 127
4 registerLogin 0x0000000102b42661 _TToFC13registerLogin14ViewController13viewDidAppearfS0_FSbT_ + 49
5 UIKit 0x00000001036cd82e -[UIViewController _setViewAppearState:isAnimating:] + 830
6 UIKit 0x00000001036ce1b0 -[UIViewController _endAppearanceTransition:] + 262
7 UIKit 0x000000010369950e -[UIPresentationController transitionDidFinish:] + 827
8 UIKit 0x0000000103857c17 -[_UICurrentContextPresentationController transitionDidFinish:] + 42
9 UIKit 0x000000010369c97e __56-[UIPresentationController runTransitionForCurrentState]_block_invoke_2 + 183
10 UIKit 0x0000000103eb105c -[_UIViewControllerTransitionContext completeTransition:] + 101
11 UIKit 0x00000001036963fb -[UITransitionView notifyDidCompleteTransition:] + 252
12 UIKit 0x000000010369610c -[UITransitionView _didCompleteTransition:] + 1344
13 UIKit 0x0000000103698878 -[UITransitionView _transitionDidStop:finished:] + 104
14 UIKit 0x00000001035c3a63 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 241
15 UIKit 0x00000001035c3e12 -[UIViewAnimationState animationDidStop:finished:] + 80
16 QuartzCore 0x000000010799bd70 _ZN2CA5Layer23run_animation_callbacksEPv + 308
17 libdispatch.dylib 0x000000010540d4bb _dispatch_client_callout + 8
18 libdispatch.dylib 0x00000001053f53ff _dispatch_main_queue_callback_4CF + 1738
19 CoreFoundation 0x0000000102c84e69 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
20 CoreFoundation 0x0000000102c463b9 __CFRunLoopRun + 2073
21 CoreFoundation 0x0000000102c45918 CFRunLoopRunSpecific + 488
22 GraphicsServices 0x000000010722dad2 GSEventRunModal + 161
23 UIKit 0x000000010354199e UIApplicationMain + 171
24 registerLogin 0x0000000102b4323d main + 109
25 libdyld.dylib 0x000000010544292d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
I have set the segues
A find in project on the term loginView only gives 2 search results see image, so i don't get where RegisterViewController "thinks" it needs loginView