在OSX中的自定义nsview类上调用方法swift时的exc_bad_access

时间:2016-09-26 04:09:42

标签: swift xcode macos nsview

这是一个简单的问题,但我无法弄清楚。

我在[AllowAnonymous] Public ActionResult ConfirmEmail(string userId, string code) { if(userId == null || code == null) { return View("Error"); } var user = UserManager.FindById(userId); if(user == null) { } else { RunAsync(ForceResetPassword(user)); return RedirectToAction("ResetPasswordAfterConfirmation","Account"); } } Public async Task<ActionResult> ForceResetPassword(ApplicationUser user) { string code = await UserManager.GeneratePasswordResetTokenAsync(user.Id); var callbackUrl = Url.Action("Reset Password", "Account", new {userId = user.Id, code = code}, protocol: Request.Url.Scheme); await UserManager.SendEmailAsync(user.Id,"Reset Password","Please reset your password by clicking <a href=\"" + callbackUrl + "\">here</a>"); //Insert send email code here } private void RunAsync(Task task) { task.ContinueWith(t => { }, TaskContinuationOptions.OnlyOnFaulted); } 中有一个名为NSWindowController的类的自定义NSView:

MyView

在我的NSWindowController(类名为MainWindowController)中,我有 导入Cocoa

import Cocoa

class MyView: NSView {

    func doNothing () {
        NSColor.green.set()
    }

    override func draw(_ dirtyRect: NSRect) {
        super.draw(dirtyRect)


    }

}

class MainWindowController: NSWindowController { @IBOutlet weak var mapaView: MyView! override var windowNibName: String { return "MainWindowController" } override func windowDidLoad() { super.windowDidLoad() window?.contentAspectRatio = mapaView.frame.size } @IBAction func aver(_ sender: AnyObject) { mapaView.frame = CGRect(x: 10.0, y: 10.0, width: 30.0, height: 50.00) mapaView.doNothing() } } NSButton

中的IBAction aver()相关联

当我点击按钮时,MainWindowController中的框架会发生变化,mapaView会因mapaView.doNothing()而崩溃

我做错了什么?

0 个答案:

没有答案