我有一个iOS动作- (void)download;
- 我在启动iOS应用程序时运行了它。
但是,我需要另一个- (void)showData;
- 在UIMapView
上显示数据,等待所有数据通过- (void)download
下载 - 在开始之前。只是想知道是否有人知道如何做到这一点?
感谢。
答案 0 :(得分:0)
首先发送- (void)download;
请求并将progress hud添加到ui,以便用户知道您正在下载数据,一旦完成下载解除进度hud并运行- (void)showData;
方法
- (void)download{
NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
if (connection) {
receivedData = [[NSMutableData data] retain];
//display loading hud here
} else {
// oh noes!
}
}
- (void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
[receivedData setLength:0];
}
- (void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[receivedData appendData:data];
int kb = [receivedData length] / 1024;
//dismiss hud here
[self showData];
}