Ios 在AppDelegate中重新加载数据

Ios 在AppDelegate中重新加载数据,ios,swift,uitableview,uiviewcontroller,appdelegate,Ios,Swift,Uitableview,Uiviewcontroller,Appdelegate,我的AppDelegate中有一个类似于DidReceiveMemoteNotification的函数,在接收到消息时将消息附加到数组,然后尝试重新加载tableview 我的应用程序只包含一个Viewcontroller和一个AppDelegate 我的代码如下所示: var myCustomViewController: ViewController = ViewController(nibName: nil, bundle: nil) println("******did

我的AppDelegate中有一个类似于DidReceiveMemoteNotification的函数,在接收到消息时将消息附加到数组,然后尝试重新加载tableview

我的应用程序只包含一个Viewcontroller和一个AppDelegate

我的代码如下所示:

    var myCustomViewController: ViewController = ViewController(nibName: nil, bundle: nil)

    println("******didReceiveMessage*****")
    myCustomViewController.messages.append(message.data.message as! String)
    println(myCustomViewController.messages)
    myCustomViewController.MessageTableView.reloadData()

然而,每当我尝试调用重载函数时,我的应用程序就会崩溃。有没有办法从我的appDelegate函数重新加载我的tableView?

您的视图尚未加载,因此该table视图尚不存在,因此它为零

不清楚您是否使用了正确的视图控制器,因为您正在创建一个新的视图控制器。对其调用
view
以创建视图(和子视图),或更改对真实现有视图控制器的引用


很可能您应该访问应用程序代理的根视图控制器
窗口

崩溃消息的内容?致命错误:在展开可选值MyCustomViewController.MessageTableView.reloadData()时意外发现为零。检查.MessageTableView是否为零。显然为零。但不应该是这样吗?