简体   繁体   中英

'NSInternalInconsistencyException' in Swift

I am new to Objective C and Swift . Here I am having an exception as 'NSInternalInconsistencyException' in my sample program. I do the following steps and this is my first program in Swift and I am not familiar in Objective C.

  1. Create an empty application name as SampleTesting
  2. Created a CheckingController.xib
  3. Created a AppDelegate.swift
  4. Created a CheckingController.swift

CheckingController.xib:

I have created a Sample Button .

AppDelegate.swift:

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?
    var navigationController: UINavigationController?

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
        self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
        // Override point for customization after application launch.
        self.window!.backgroundColor = UIColor.whiteColor()
        self.window!.makeKeyAndVisible()

        var mainController: CheckingController? = CheckingController(nibName: "CheckingController", bundle: nil)
        self.navigationController = UINavigationController(rootViewController: mainController)
        self.window!.rootViewController = self.navigationController
        return true
    }

    func applicationWillResignActive(application: UIApplication) {

    }

CheckingController.swift:

import Foundation
import UIKit

class CheckingController: UIViewController{

    init(nibName nibNameOrNil: String!, bundle nibBundleOrNil: NSBundle!) {
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
    }

    override func viewDidLoad() {

        super.viewDidLoad()
    }
}

Need some guidance on what could be going wrong here and how to resolve it.

Thanks.

I followed the below steps and i fixed the error:

  1. Open the XIB file causing problems
  2. Click on file's owner icon on the left bar (top one, looks like a yellow outlined box) If you don't see the right-hand sidebar, click on the third icon above “view” in your toolbar. This will show the right-hand sidebar
  3. In the right-hand sidebar, click on the third tab–the one that looks a bit like a newspaper
  4. Under “Custom Class” at the top, make sure Class is the name of the ViewController that should correspond to this view. If not, enter it In the right-hand sidebar, click on the last tab–the one that looks like a circle with an arrow in it
  5. You should see “outlets” with “view” under it. Drag the circle next to it over to the “view” icon on the left bar (bottom one, looks like a white square with a thick gray outline
  6. Save the xib and re-run

Refered here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM