我正在创建一个应用程序,我可以通过此功能调用我的API:
func serverCallAPI(function:String,
success:((result:NSDictionary) -> Void)?) -> Void {
//code here to set up request to send with NSURLConnection
let connection:NSURLConnection = NSURLConnection(request: request,
delegate: self,
startImmediately: true)!
//I WANT TO RUN THE PASSED ON SUCCESS FUNCTION WHEN connectionDidFinishLoading IS CALLED.
}
我的问题是,在完成connectionDidFinishLoading处理时,我无法想到调用传递成功函数的方法。你怎么能这样做?