NSURLConnection Async Request and display a “Loading” alert view or subview while fulfilling request?

Probably the easiest way to do it is to use the UIApplication. NetworkActivityIndicatorVisible property, and do a sync request in a background thread.

Probably the easiest way to do it is to use the UIApplication. NetworkActivityIndicatorVisible property, and do a sync request in a background thread. -(void)loadURLInBackground:(NSURL*)url { NSURLRequest* req = NSURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0; NSURLResponse* response = nil; NSError* err = nil; UIApplication sharedApplication.

NetworkActivityIndicatorVisible = YES; NSData* data = NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&err; UIApplication sharedApplication. NetworkActivityIndicatorVisible = NO; if( data! = nil ) { self performSelectorOnMainThread:@selector(processData:) withObject:data waitUntilDone:NO; } else { self performSelectorOnMainThread:@selector(processError:) withObject:err waitUntilDone:NO; } } Use self performSelectorInBackground:@selector(loadURLInBackground:) withObject:url; to call the method, then just implement processData: and processError:.

You do not want to use a UIAlertView - that is a modal dialog. You want to use something like UIActivityIndicatorView to show the spinner while the background activity is going on. Then, as you say, your delegate method can stopAnimating the activity indicator view.

If you want to show a message like "Downloading ...", then you can wrap your activity indicator inside another view, display that view, and remove it when the delegate calls back.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions