点击一个按钮后,我打电话给一个Web服务,之后我推送一个UIViewController
。我的UIViewController
应该加载从Web服务获得的数据。但是目前,在我的网络服务被调用之前,UIViewController
正在被推送。我可以做些什么来确保我的UIViewController
在所有Web服务调用和数据检索之前都未加载。只有在调用所有Web服务后才执行一段代码
这是我使用的代码。
MyWebService *webservice = [MyWebService myWebService];
webservice.delegate = self;
[webservice getMyDataWithMyNumber:mySharedNumber myOldNumber:temp];
[webservice getvDetailsWithmyData:myData myNumber:myNumber];
MyViewController *myViewController = [[MyViewController alloc]initWithNibName:@"MyViewController" bundle:nil];
[self.navigationController pushViewController: myViewController animated:YES];
[myViewController release];
编辑:UIViewController
只有在两个Web服务被调用后才应该推送。 我正在将一个数组传递给新的UIViewController
。数组对象在Web服务调用期间添加。我无法找到一种方法来做到这一点。需要帮忙。谢谢。
修订我不熟悉代表团模式。你可以挑起一些例子或链接。 – 2012-03-21 18:07:15
阅读Cocoa基础指南中的部分:https://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/CommunicateWithObjects.html#//apple_ref/doc/uid/TP40002974-CH7 -SW18 – bandejapaisa 2012-03-21 18:53:11
我不明白如何使用委托将确保所有其他代码只有在Web服务调用完成后才会执行。 – 2012-03-21 19:02:08