本文介绍了Swift /可可中的windowNibName错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,这将教我开始一年半的Swift编程工作。显然情况已经改变了。



在我以前的程序中,MainWindowController内部的内容很高兴:

 类MainWindowController:NSWindowController {

覆盖var windowNibName:字符串? {
return MainWindowController
}
...

但是现在我遇到了这个错误:

我一直在Google搜索和搜索Stack Overflow,但一直无法弄清楚确切的含义问题是以及如何解决它。在过去的一年半中,这方面发生了什么变化?



预先感谢!

解决方案

现在将 windowNibName 的类型从 String 替换为 struct 。 / p>

您可以在。
要纠正错误,可以使用以下代码:

  class MainWindowController:NSWindowController {

是否覆盖var windowNibName:NSNib.Name? {
return NSNib.Name( MainWindowController)
}
}





 打开var windowNibName:NSNib.Name? {get} 


Well, that will teach me to set down Swift programming for a year and a half. Apparently things have changed.

In my past programs, this inside my MainWindowController was quite happy:

class MainWindowController: NSWindowController {

    override var windowNibName: String? {
        return "MainWindowController"
    }
...

But now I'm getting this error:

I've been Googling and poking around Stack Overflow but have been unable to figure out what the exact problem is and how to fix it. What has changed over the last year and a half in this regard? Ideas would be most welcome.

Thanks in advance!

解决方案

Now type of windowNibName replace to struct from String.

You can check more details here.To fix error you can use below code :

class MainWindowController: NSWindowController {

    override var windowNibName: NSNib.Name? {
        return NSNib.Name("MainWindowController")
    }
}
    open var windowNibName: NSNib.Name? { get }

这篇关于Swift /可可中的windowNibName错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-19 00:50