简体   繁体   中英

Xcode Mac application (Swift) problems

I am working on a Mac application using Swift.

And I got a lot of problems there cause I thought it would be the same as I did it in the iOS application

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 {

@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'

Code:

self.dismissViewControllerAnimated(true, completion: nil)

The last one:

The error: Use of unresolved identifier '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.

UIAlertController is part of UIKit Library which is only available on 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM