I am making an app with a sign up and login. I used Parse for this. I want to move the View Controller to a TableViewController if the Login/Sign Up is successful. However I am getting this error: "Cannot convert value type'TableViewController.Type' to expected argument type 'UIViewController'.
Here is the line I am getting the error in:
func logInViewController(logInController: PFLogInViewController, didLogInUser user: PFUser) {
self.dismissViewControllerAnimated(true, completion: nil)
self.presentViewController(TimelineTableViewController, animated: true, completion: nil)
}
And here is the whole code:
// Created by Ojas Sethi on 12/10/15.
// Copyright © 2015 Jell Apps. All rights reserved.
//
import UIKit
import Parse
import ParseUI
class LoginSignupViewController: UIViewController, PFLogInViewControllerDelegate, PFSignUpViewControllerDelegate {
var logInViewController: PFLogInViewController = PFLogInViewController()
var signUpViewController: PFSignUpViewController = PFSignUpViewController()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
if (PFUser.currentUser() == nil){
self.logInViewController.fields = PFLogInFields.UsernameAndPassword
self.logInViewController.fields = PFLogInFields.LogInButton
self.logInViewController.fields = PFLogInFields.SignUpButton
self.logInViewController.fields = PFLogInFields.PasswordForgotten
self.logInViewController.fields = PFLogInFields.DismissButton
/*| PFLogInFields.LogInButton | PFLogInFields.SignUpButton | PFLogInFields.PasswordForgotten | PFLogInFields.DismissButton*/
let logoInLogoTitle = UILabel()
logoInLogoTitle.text = "Ziffer"
logoInLogoTitle.font = UIFont.systemFontOfSize(25)
self.logInViewController.logInView?.logo = logoInLogoTitle
self.logInViewController.delegate = self
let signUpLogoTitle = UILabel()
signUpLogoTitle.text = "Ziffer"
logoInLogoTitle.font = UIFont.systemFontOfSize(25)
self.signUpViewController.signUpView?.logo = signUpLogoTitle
self.signUpViewController.delegate = self
self.logInViewController.signUpController = self.signUpViewController
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func logInViewController(logInController: PFLogInViewController, shouldBeginLogInWithUsername username: String, password: String) -> Bool {
if (!username.isEmpty || !password.isEmpty){
return true
}else{
return false
}
}
func logInViewController(logInController: PFLogInViewController, didLogInUser user: PFUser) {
self.dismissViewControllerAnimated(true, completion: nil)
self.presentViewController(TimelineTableViewController, animated: true, completion: nil)
}
func logInViewController(logInController: PFLogInViewController, didFailToLogInWithError error: NSError?) {
print("failed to login")
}
func signUpViewController(signUpController: PFSignUpViewController, didSignUpUser user: PFUser) {
self.dismissViewControllerAnimated(true, completion: nil)
self.presentViewController(logInViewController, animated: true, completion: nil)
SignUpSuccessfulAlert()
}
func signUpViewController(signUpController: PFSignUpViewController, didFailToSignUpWithError error: NSError?) {
print("Failed to signup...")
SignUpFaliedAlert()
}
func signUpViewControllerDidCancelSignUp(signUpController: PFSignUpViewController) {
print("User dismissed sign up.")
}
func SignUpSuccessfulAlert(){
var alertController : UIAlertController
alertController = UIAlertController(title: "Sign Up Successful", message: "Yay! Sign up was successful! Now you can start using Ziffer!", preferredStyle: .Alert)
let doneAction = UIAlertAction(title: "Ok", style: .Default, handler: nil)
alertController.addAction(doneAction)
self.presentViewController(alertController, animated: true, completion: nil)
}
func SignUpFaliedAlert(){
var signUpalertFail : UIAlertController
signUpalertFail = UIAlertController(title: "Failed", message: "Sorry! Sign up faield. Check the connections and try again later", preferredStyle: .Alert)
let okAction = UIAlertAction(title: "Ok", style: .Default, handler: nil)
signUpalertFail.addAction(okAction)
self.presentViewController(signUpalertFail, animated: true, completion: nil)
}
}