I am getting list using url by doing parsing it using xml parser. sometimes the server is not working properly. then how to give an alert when server is not working properly. I have given the code below
-(NSMutableArray*)getCustomerList:(NSString *)count category:(NSString *)aCategory alphabetic:(NSString *)alphabeticValue favorite:(NSString *)isFavoriteString
{
[self updateStatus];
if (internetConnectionStatus == NotReachable)
{
UIAlertView *reachbleAlert = [[UIAlertView alloc] initWithTitle:@"message"
message: @"No network available alert"
delegate:self
cancelButtonTitle:@"Ok"
otherButtonTitles: nil];
[reachbleAlert show];
[reachbleAlert release];
return 0;
}
else
{
NSString *urlString=@"http:getCustomerList.jsp";
urlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[dataParser parseXMLFileAtURL:[NSURL URLWithString:urlString]];
NSMutableArray *list =[dataParser getCustomerListFromParser];
printf("\n url for Customer List%s",[urlString UTF8String]);
printf("\n Customer List %d",[list count]);
return list;
}
}
I am sending parameter to url to return repctive list when it returns zero I am dispalying alert in view controller.
but when server is not working properly then how to display this alert.
Please help me out of this.
Thank you,
Madan mohan.
In my opinion :
First perform the request operation to the server for any response.
Secondly Catch the the response received in a BOOL variable .
Finally when your BOOL variable is TRUE perform the desired operation [Such as parsing..]
Otherwise just show an alert message with a proper error message.