I am loading the JSON channel asynchronously into the App Delegate class. Now the data is loaded for a while, so first an empty view of the table opens, and then it is filled in a few seconds. Therefore, I would like to either:
1- Find out what causes this delay. Therefore, save all the actions in the application: the didFinishLaunchingWithOptions method and load VC only after everything has been loaded.
OR
2 Display the activity indicator until the table fills in the data.
Now in the first scenario, I'm sure that I am pushing the view controller at the wrong time. I tried playing with it, but it seems that this is the only way my application will create and run.
In the second scenario, I would like to know which method "connection" is started first and which last. Therefore, I can start the activity indicator view by the first method and release it at the end of the last method.
Below is my code. Any suggestions / help are appreciated. Thanks for reading.
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { [responseData setLength:0]; } - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [responseData appendData:data]; } - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Please check your network connection and relaunch the application" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil, nil]; [alert show]; [alert release]; } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; if ([responseString isEqualToString:@"Unable to find specified resource."]) { NSLog(@"Unable to find specified resource.n"); } else { ListingsViewController *listingsViewController = [[ListingsViewController alloc] initWithNibName:@"ListingsViewController" bundle:nil]; listingsViewController.jsonData = responseString; [self.navigationController pushViewController:listingsViewController animated:NO]; [self.navigationController setViewControllers:[NSArray arrayWithObject:listingsViewController] animated:NO]; [listingsViewController release]; } [connection release]; [responseData release]; } - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
source share