ViewController.h
================
@interface ViewController : UIViewController{
UIAlertView *alertLoader;
}
@end
ViewController.m
================
- (void)viewDidLoad
{
[super viewDidLoad];
[self methodtocallWebservices];
}
-(void)methodtocallWebservices{
alertLoader = [[UIAlertView alloc] initWithTitle:@"" message:@"Please Wait..." delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
alertLoader.tag=1;
[alertLoader show];
}
- (void)didPresentAlertView:(UIAlertView *)alertView
{
if (alertView.tag== 1) {
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
indicator.center = CGPointMake(alertView.bounds.size.width/2, alertView.bounds.size.height/3 * 2);
[indicator startAnimating];
[alertView addSubview:indicator];
NSString *hostStr = @"@"http://rajuandroid.blogspot.com/api/contact_name_json";
NSURL *url = [[NSURL alloc] initWithString:hostStr];
NSLog(@"login url: %@",url);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[[[NSURLConnection alloc] initWithRequest:request delegate:self] autorelease];
[url release];
}
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
// [self.receivedData appendData:data];
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{
[self stopLoading];
//[self handleError:error];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection{
[self stopLoading];
}
-(void)stopLoading
{
dispatch_async(dispatch_get_main_queue(), ^{
[alertLoader dismissWithClickedButtonIndex:0 animated:YES];
[alertLoader release];
});
}
================
@interface ViewController : UIViewController{
UIAlertView *alertLoader;
}
@end
ViewController.m
================
- (void)viewDidLoad
{
[super viewDidLoad];
[self methodtocallWebservices];
}
-(void)methodtocallWebservices{
alertLoader = [[UIAlertView alloc] initWithTitle:@"" message:@"Please Wait..." delegate:self cancelButtonTitle:nil otherButtonTitles:nil];
alertLoader.tag=1;
[alertLoader show];
}
- (void)didPresentAlertView:(UIAlertView *)alertView
{
if (alertView.tag== 1) {
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
indicator.center = CGPointMake(alertView.bounds.size.width/2, alertView.bounds.size.height/3 * 2);
[indicator startAnimating];
[alertView addSubview:indicator];
NSString *hostStr = @"@"http://rajuandroid.blogspot.com/api/contact_name_json";
NSURL *url = [[NSURL alloc] initWithString:hostStr];
NSLog(@"login url: %@",url);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[[[NSURLConnection alloc] initWithRequest:request delegate:self] autorelease];
[url release];
}
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
// [self.receivedData appendData:data];
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{
[self stopLoading];
//[self handleError:error];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection{
[self stopLoading];
}
-(void)stopLoading
{
dispatch_async(dispatch_get_main_queue(), ^{
[alertLoader dismissWithClickedButtonIndex:0 animated:YES];
[alertLoader release];
});
}