<分区>
我正在使用 Swift
和最新的 Xcode
版本。
我在 AppDelegate.swift
中有这段代码:
func testPrint(string: String) {
print(string)
}
我可以像这样从文件 ViewController.swift
中成功调用该函数:
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.testPrint(string: "Hello!")
但是,如果我尝试从 TodayViewController.swift
调用该函数,它适用于 Apples Today Extension
,我会收到以下错误:
Use of undeclared type 'AppDelegate'
为什么?