cocoabits/MASPreferences

Getting exception when loading preferences screen

bipinvaylu opened this issue · 2 comments

I am newbie using MASPreferences in Swift and Storyboard for design.

Following is my application code:
AppDelegate.swift

 @IBAction func openPreferences(sender: AnyObject) {
        preferencesWindowController().showWindow(sender)
    }

func preferencesWindowController() -> NSWindowController {
        if mPreferencesWindowController == nil {
            let accountViewController: NSViewController = AccountViewController()
            let advanceViewController: NSViewController = AdvanceViewController()
            let controllers : [AnyObject] = [accountViewController, advanceViewController]
            let title: String = NSLocalizedString("Preferences", comment: "Common title for Preferences window")
            self.mPreferencesWindowController = MASPreferencesWindowController(viewControllers: controllers, title: title)
        }
        return mPreferencesWindowController!
    }

AccountViewController.swift

class AccountViewController: NSViewController, MASPreferencesViewController {
    //Other codes
    override var identifier: String? { get {return "Account"} set { super.identifier = newValue} }

    var toolbarItemImage: NSImage! {
        return NSImage(named : "Account")!
    }

    var toolbarItemLabel: String {
        return "Account"
    }
}

Getting this exception:

2015-11-27 01:34:28.554 ottodj[36666:4245308] -[NSNib _initWithNibNamed:bundle:options:] could not load the nibName: ottodj.AccountViewController in bundle (null).
2015-11-27 01:34:28.556 ottodj[36666:4245308] (
    0   CoreFoundation                      0x00007fff968b7e32 __exceptionPreprocess + 178
    1   libobjc.A.dylib                     0x00007fff885864fa objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff9691e65d +[NSException raise:format:] + 205
    3   AppKit                              0x00007fff9382f70f -[NSNib _initWithNibNamed:bundle:options:] + 608
    4   AppKit                              0x00007fff9382f465 -[NSViewController _nibWithName:bundle:] + 127
    5   AppKit                              0x00007fff9382f0bf -[NSViewController loadView] + 129
    6   AppKit                              0x00007fff9379c662 -[NSViewController _loadViewIfRequired] + 75
    7   AppKit                              0x00007fff9379c5cd -[NSViewController view] + 30
    8   MASPreferences                      0x0000000100361c2e -[MASPreferencesWindowController setSelectedViewController:] + 862
    9   MASPreferences                      0x0000000100362b1f -[MASPreferencesWindowController toolbarItemDidClick:] + 127
    10  AppKit                              0x00007fff93a9947e -[NSToolbarButton sendAction:to:] + 75
    11  AppKit                              0x00007fff939c6e03 -[NSToolbarItemViewer mouseDown:] + 4996
    12  AppKit                              0x00007fff93f1a42d -[NSWindow _handleMouseDownEvent:isDelayedEvent:] + 6322
    13  AppKit                              0x00007fff93f1b411 -[NSWindow _reallySendEvent:isDelayedEvent:] + 212
    14  AppKit                              0x00007fff93960b8d -[NSWindow sendEvent:] + 517
    15  AppKit                              0x00007fff938e0b27 -[NSApplication sendEvent:] + 2540
    16  AppKit                              0x00007fff93747d9a -[NSApplication run] + 796
    17  AppKit                              0x00007fff93710fbe NSApplicationMain + 1176
    18  ottodj                              0x000000010006e307 main + 87
    19  libdyld.dylib                       0x00007fff92e375ad start + 1
    20  ???                                 0x0000000000000003 0x0 + 3
)

Can you please guide me if i am missing something.
Thanks in advance!

Seeing this as well. Oddly doesn't happen to me but only for some users. Started happening it when I added a new preference view and controller that uses Swift.

The exception says: “could not load the nibName: ottodj.AccountViewController in bundle (null).”

This indicates that your sample project lack a bundle/bundle identifier.

Closing as I believe this to be user error, provide a full project showing this issue if you want further help.