[英]Xcode Mac application (Swift) problems
I am working on a Mac application using Swift.我正在使用 Swift 开发 Mac 应用程序。
And I got a lot of problems there cause I thought it would be the same as I did it in the iOS application我在那里遇到了很多问题,因为我认为这与我在 iOS 应用程序中所做的相同
I am really sorry about this long post :(我真的很抱歉这篇长篇文章:(
The first problem:第一个问题:
The error: "Method does not override any method from its superclass"错误:“方法不会覆盖其超类中的任何方法”
The code:编码:
import Cocoa
class CreateAccountViewController: NSViewController {类 CreateAccountViewController: NSViewController {
@IBOutlet weak var emailTextField: NSTextField!
@IBOutlet weak var passwordTextField: NSSecureTextField!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
The next one:下一个:
Error:Value of type 'CreateAccountViewController' has no member 'dismissViewControllerAnimated'错误:“CreateAccountViewController”类型的值没有成员“dismissViewControllerAnimated”
Code:代码:
self.dismissViewControllerAnimated(true, completion: nil)
The last one:最后一个:
The error: Use of unresolved identifier 'UIAlertController'错误:使用未解析的标识符“UIAlertController”
The code:编码:
let alert = UIAlertController(title: "Error", message: "Enter Email and Password", preferredStyle: .Alert)
I am so sorry but this is my first time I wrote a Mac application.我很抱歉,但这是我第一次编写 Mac 应用程序。
UIAlertController
is part of UIKit
Library which is only available on iOS. UIAlertController
是UIKit
库的一部分,仅在 iOS 上可用。
You'll need to use NSAlert
to pop an alert in a window on Mac OS X. You also need to do an import AppKit
at the top of your Swift file.您需要使用NSAlert
在 Mac OS X 的窗口中弹出警报。您还需要在 Swift 文件的顶部执行import AppKit
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.