在操作完成之前调用视图

时间:2014-06-08 19:25:35

标签: ios uinavigationcontroller nsurlconnection

我有一个用于下载数据和创建本地数据库的按钮。比,我想用这些数据打开一个表格视图。它工作但似乎在进行db cratio / actualization之前调用了表视图。

按钮的代码是:

-(IBAction)downloadButton:(id)sender{

    [controller dowloadingFunction];  //contains soem function based on NS

    //the navigation controller to call the tableview
    ViewController *tableController =[[ViewController alloc]init];
    [self.navigationController pushViewController:tableController animated:NO];
}

dowloadingFunction基本上做了:

{
...
   // perform the reqeust
    NSURLResponse *response;
    NSError *myError = nil;

    NSData *data = [NSURLConnection
                    sendSynchronousRequest: request
                    returningResponse: &response
                    error: &myError];

    NSURLConnection *connectionPlatos = [[NSURLConnection alloc] initWithRequest:request delegate:self];
    [connectionPlatos start];
}

当连接接收数据时,我调用“parseJson”函数来解析并创建数据库。

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)d {

    NSString *string = [[NSString alloc] initWithData:d encoding:NSUTF8StringEncoding];
    //    NSLog(@"connection didReceiveData: %@",string);
    jsonPlatos = string;

    [self parseJson:jsonPlatos];      //<---- Funcion  to parse and create data base.

}

我的问题是如何在调用导航控制器之前使数据库的创建结束。有什么帮助吗?

0 个答案:

没有答案