I have written an app that downloads and then scrapes data from an html file. The app has been working fine for months, but the last couple of days it has stopped.
Here is the code...
NSString* urlString = [@"http://easytide.ukho.gov.uk/EASYTIDE/EasyTide/ShowPrediction.aspx?PortID=" stringByAppendingString:portCode];
urlString = [urlString stringByAppendingString:@"&PredictionLength=7"];
NSURL* easyTidesUrl = [NSURL URLWithString:urlString];
NSData* easyTidesHtmlData = [NSData dataWithContentsOfURL:easyTidesUrl];
When I examine the NSURL object, the url has not set properly (there is an error with the string) and the NSURL object is shown as . I know similar questions have been asked in the past (i have tried the solutions and they don't work in this instance), but it seems bizarre that the app was working fine and is now broken without doing anything to it!
Here is some more code... basically the part that has stopped working is the first part of the function...
+(void)getTides:(NSMutableArray *)tidalDateArray withPortCode:(NSString*)portCode
{
NSString *parameter = [portCode stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *urlString = [NSString stringWithFormat:@"http://easytide.ukho.gov.uk/EASYTIDE/EasyTide/ShowPrediction.aspx?PortID=%@&PredictionLength=7", parameter];
NSURL *easyTidesUrl = [NSURL URLWithString:urlString];
NSData *easyTidesHtmlData = [NSData dataWithContentsOfURL:easyTidesUrl];
TFHpple* tidesParser = [TFHpple hppleWithHTMLData:easyTidesHtmlData];
NSString* easyTidesXPathQueryString = @"//div[@class='HWLWPanel']/table/tr/th[@class='HWLWTableHeaderCell']";
NSArray* tideDateNodes = [tidesParser searchWithXPathQuery:easyTidesXPathQueryString];
NSDateComponents *components = [[NSCalendar currentCalendar] components:NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit fromDate:[NSDate date]];
NSCalendar *gregorian = [[NSCalendar alloc]
initWithCalendarIdentifier:NSGregorianCalendar];