我正在尝试检索实际的视图控制器并调用方法来更改ProgressIndicator。
我的AppDelegate中有以下功能
func applicationDidFinishLaunching(_ aNotification: Notification) {
let main = NSStoryboard(name: "Main", bundle: Bundle.main)
let vc = main.instantiateController(withIdentifier: "Installing") as! ViewController
vc.incrementBar(number: 20)
}
incrementBar函数如下
@IBOutlet weak var progressView: NSProgressIndicator!
public func incrementBar(number: Double){
if(self.progressView != nil){
print(number)
self.progressView.increment(by: number)
}
}
只是为了确定。我可以从viewDidLoad()或viewDidAppear()轻松调用此函数,但是当我尝试接收实际的控制器时,它会告诉我progressView是nil