«Тип выражения неоднозначен без дополнительного контекста» в .RunLoop.Modes.default при установке таймера - PullRequest
0 голосов
/ 14 октября 2019

Вот мой AppDelegate.swift:

import Cocoa

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {  
    var window: NSWindow!

    func applicationDidFinishLaunching(_ aNotification: Notification) {
        let timer = Timer(fire: Date(), interval: 60, repeats: true, block: { timer in
            print("timer")
        })

        RunLoop.current.add(timer, forMode: .RunLoop.Modes.default)
    }
}

В этой строке RunLoop в конце отображается ошибка (особенно в части .RunLoop.Modes.default):

Тип выражения неоднозначен без контекста.

Есть идеи, что мне здесь не хватает?

1 Ответ

2 голосов
/ 14 октября 2019

Можете ли вы попробовать это:

func applicationDidFinishLaunching(_ aNotification: Notification) {
    let timer = Timer(fire: Date(), interval: 60, repeats: true, block: { timer in
        print("timer")
    })

    RunLoop.current.add(timer, forMode: .default)
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...