我的应用程序中有2个ViewControllers.其中一个名为vcA的方法是使用一种方法(此处为viewDidLoad)与我的网络层(我的应用程序中的一个类)进行通信.在完成网络作业(将由完成处理程序推断)后,我想通知类vcB调用一个方法来获取网络层提供的一些数据.请看下面的sudo代码:
class Networking {
static var PublicValue : SomeKindOfClass? = nil
static func test(completionHandler : (successful : Bool) -> Void) -> Void {
//Do some networking in background
Network.BackgroundNetworking() {
if result = true {
PublicValue = SomeValue
completionHandler(successful : true)
}
else {
completionHandler(successful : false)
}
}
}
class vcA : UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
Networking.test(completionHandler : { (successful) in
if successful == true {
//Here …Run Code Online (Sandbox Code Playgroud) 我有一个安装了Apache2,Swift 3.1.1和Vapor的VPS(Ubuntu 14.04).我希望通过HTTPS协议(例如,在端口8443上)接收客户端对我的Vapor-Built-Service的请求.我没有找到任何新手助手文件,所以请帮助我.
谢谢.