Trying to alert user when internet is unavailable (and retry when they dismiss message). The screen slightly dims (in preparation for alert), but the alert never displays.
Is the while loop interfering with the alert?
-(NSArray*)getResponse:(NSString*)page {
NSError *error;
NSURLResponse *response;
NSData *dataReply;
NSString *stringReply;
NSString *legalAddressURL;
NSArray *separatedData;
legalAddressURL = [NSString stringWithFormat:@"%@%@", SERVER,
[page stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: [NSURL URLWithString: legalAddressURL]];
[request setHTTPMethod: @"GET"];
dataReply = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
while ([error code]){
if (isNetAvailable){
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Internet Connection"
message:@"Server is down" delegate:self cancelButtonTitle:@"Try again"
otherButtonTitles:nil] autorelease];
[alert show];
dataReply = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
} else {
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Internet Connection"
message:@"No access to net" delegate:self cancelButtonTitle:@"Try again"
otherButtonTitles:nil] autorelease];
[alert show];
dataReply = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
}
}
stringReply = [[NSString alloc] initWithData:dataReply encoding:NSUTF8StringEncoding];
separatedData = [stringReply componentsSeparatedByCharactersInSet:
[NSCharacterSet characterSetWithCharactersInString:@","]];
return separatedData;
}