首先我认为 Xcode 有问题,所以我重新启动了 Xcode,但即使在重新启动 mac 后问题仍然存在。然后我发现,后面的分号.default
或另一个变量的声明可以修复它。
我认为 Xcode 认为任务在之后还没有结束.default
,但我很好奇是否还有更多内容/更好的解释为什么会这样。
func setupNotificationHandling() {
let notificationCenter = NotificationCenter.default
// Can't access notificationCenter via autocompletion here
}