在开始我的学校主要项目编码之前,我正在根据教程( https://www.youtube.com/watch?v=B6W2Rp8Uumo&feature=youtu.be )进行测试。一切都很顺利,直到我遇到错误。
void 函数中出现意外的非 void 返回值。
我已经阅读了有关此问题的其他帖子,但无法找到具体需要更改的内容。代码如下所示:
@UIApplicationMain AppDelegate 类:UIResponder、UIApplicationDelegate {
var window: UIWindow?
var MainVC:MainViewController?
func application(_application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?)
{
MainVC = MainViewController(nibName: "MainViewController", bundle: nil)
let frame = UIScreen.main.bounds
window = UIWindow(frame: frame)
window!.rootViewController = MainVC
window!.makeKeyAndVisible()
return true //this is where the error occurs
}
如果有人可以帮助我解决这个问题并解释这个错误的含义,那就太棒了!
最佳答案
方法签名末尾应有-> Bool
。这告诉编译器该方法将返回一个 bool 值。检查this .
关于swift - void 函数中返回 true 时出现意外的非 void 返回值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56104828/