David
David

Reputation: 163

Swift xcode error: Thread 1 signal SIGABRT "instantiated view controller from storyboard but didn't get a UITableView

The purpose of this project is to create a login and account activation screen that can move between each other by clicking the buttons which will activate the segues that move to and from each screen.

Here is the error:

2016-03-02 18:13:33.979 FinalProjectDavid[7609:406027] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] instantiated view controller with identifier "UIViewController-BYZ-38-t0r" from storyboard "Main", but didn't get a UITableView.'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000105e1be65 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000107b5bdeb objc_exception_throw + 48
    2   CoreFoundation                      0x0000000105e1bd9d +[NSException raise:format:] + 205
    3   UIKit                               0x0000000106a19af4 -[UITableViewController loadView] + 638
    4   UIKit                               0x00000001067ceb74 -[UIViewController loadViewIfRequired] + 138
    5   UIKit                               0x00000001067d4f4f -[UIViewController __viewWillAppear:] + 120
    6   UIKit                               0x0000000106804e44 -[UINavigationController _startCustomTransition:] + 1203
    7   UIKit                               0x000000010681523f -[UINavigationController _startDeferredTransitionIfNeeded:] + 712
    8   UIKit                               0x00000001068163af -[UINavigationController __viewWillLayoutSubviews] + 57
    9   UIKit                               0x00000001069bcff7 -[UILayoutContainerView layoutSubviews] + 248
    10  UIKit                               0x00000001066ef4a3 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 703
    11  QuartzCore                          0x000000010aba159a -[CALayer layoutSublayers] + 146
    12  QuartzCore                          0x000000010ab95e70 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
    13  QuartzCore                          0x000000010ab95cee _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
    14  QuartzCore                          0x000000010ab8a475 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277
    15  QuartzCore                          0x000000010abb7c0a _ZN2CA11Transaction6commitEv + 486
    16  UIKit                               0x0000000106632f7c _UIApplicationHandleEventQueue + 7329
    17  CoreFoundation                      0x0000000105d47a31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    18  CoreFoundation                      0x0000000105d3d95c __CFRunLoopDoSources0 + 556
    19  CoreFoundation                      0x0000000105d3ce13 __CFRunLoopRun + 867
    20  CoreFoundation                      0x0000000105d3c828 CFRunLoopRunSpecific + 488
    21  GraphicsServices                    0x000000010a42ead2 GSEventRunModal + 161
    22  UIKit                               0x0000000106638610 UIApplicationMain + 171
    23  FinalProjectDavid                   0x0000000105c32bbd main + 109
    24  libdyld.dylib                       0x000000010866492d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

Thread 1 error screenshot: enter image description here

Storyboard Screenshot: enter image description here

AppDelegate class

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate
{

    var window: UIWindow?


    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
        return true
    }

    func applicationWillResignActive(application: UIApplication) {
        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
        // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
    }

    func applicationDidEnterBackground(application: UIApplication) {
        // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }

    func applicationWillEnterForeground(application: UIApplication) {
        // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
    }

    func applicationDidBecomeActive(application: UIApplication) {
        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    }

    func applicationWillTerminate(application: UIApplication) {
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    }


}

ViewController class

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    @IBOutlet weak var Label: UILabel!
    @IBOutlet weak var UsernameTextField: UITextField!

    @IBOutlet weak var PasswordTextField: UITextField!

    @IBOutlet weak var SignInButton: UIButton!

    @IBAction func PressedSignInButton(sender: UIButton)
    {
        var usr = "car"
        var pwd = "123"

        if UsernameTextField.text == usr && PasswordTextField.text == pwd
        {

            Label.text = "The credentials were correct."
            UsernameTextField.resignFirstResponder()
            PasswordTextField.resignFirstResponder()
        }
        else
        {
            Label.text = "The crendeitals were not correct."
            UsernameTextField.resignFirstResponder()
            PasswordTextField.resignFirstResponder()

        }

    }




}

Create Account Page class:

import UIKit

class CreateAccountPage: UITableViewController
{
    @IBOutlet weak var UserNameTextField: UITextField!

    @IBOutlet weak var PasswordTextField: UITextField!

    @IBOutlet weak var EmailAddressTextField: UITextField!

    @IBOutlet weak var ActivateButton: UIButton!
    @IBOutlet weak var ReturnButton: UIButton!

    @IBAction func PressedActivateButton(sender: UIButton)
    {
     var username = UserNameTextField.text
        var password = PasswordTextField.text
        var EmailAddress = EmailAddressTextField.text

        // create the alert
        let alert = UIAlertController(title: "Activated", message: "Your new account is now activated.", preferredStyle: UIAlertControllerStyle.Alert)

        // add an action (button)
        alert.addAction(UIAlertAction(title: "Okay", style: UIAlertActionStyle.Default, handler: nil))

        // show the alert
        self.presentViewController(alert, animated: true, completion: nil)



    }

    @IBAction func ReturnButton(sender: UIButton)
    {
    }
    //performSegueWithIdentifier("mySegueID", sender: nil




}

Upvotes: 0

Views: 2310

Answers (1)

nhgrif
nhgrif

Reputation: 62072

The CreateAccountPage inherits from UITableViewController. UITableViewController (and its subclasses) must have a UITableView for its view property.

Your problem can be resolved by changing the CreateAccountPage to inherit from a regular UIViewController rather than a UITableViewController.

Upvotes: 2

Related Questions