簡體   English   中英

Xcode Mac 應用程序 (Swift) 問題

[英]Xcode Mac application (Swift) problems

我正在使用 Swift 開發 Mac 應用程序。

我在那里遇到了很多問題,因為我認為這與我在 iOS 應用程序中所做的相同

我真的很抱歉這篇長篇文章:(

第一個問題:

錯誤:“方法不會覆蓋其超類中的任何方法”

編碼:

import Cocoa

類 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.
}

下一個:

錯誤:“CreateAccountViewController”類型的值沒有成員“dismissViewControllerAnimated”

代碼:

self.dismissViewControllerAnimated(true, completion: nil)

最后一個:

錯誤:使用未解析的標識符“UIAlertController”

編碼:

let alert = UIAlertController(title: "Error", message: "Enter Email and Password", preferredStyle: .Alert)

我很抱歉,但這是我第一次編寫 Mac 應用程序。

UIAlertControllerUIKit庫的一部分,僅在 iOS 上可用。

您需要使用NSAlert在 Mac OS X 的窗口中彈出警報。您還需要在 Swift 文件的頂部執行import AppKit

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM