In my appDelegate in didFinishLaunchingWithOptions, I have the following:
NSURL *url = [NSURL URLWithString:@"http://www.thejenkinsinstitute.com/Journal/"];
NSString *content = [NSString stringWithContentsOfURL:url];
NSString * aString = content;
NSMutableArray *substrings = [NSMutableArray new];
NSScanner *scanner = [NSScanner scannerWithString:aString];
[scanner scanUpToString:@"<p>To Download the PDF, " intoString:nil]; // Scan all characters before #
while(![scanner isAtEnd]) {
NSString *substring = nil;
[scanner scanString:@"<p>To Download the PDF, <a href=\"" intoString:nil]; // Scan the # character
if([scanner scanUpToString:@"\"" intoString:&substring]) {
// If the space immediately followed the #, this will be skipped
[substrings addObject:substring];
}
[scanner scanUpToString:@"" intoString:nil]; // Scan all characters before next #
}
// do something with substrings
NSString *URLstring = [substrings objectAtIndex:0];
self.theheurl = [NSURL URLWithString:URLstring];
NSLog(@"%@", theheurl);
[substrings release];
The console printout for theheurl gives me a valid URL ending in .pdf.
In the class I would like to load the URL, I have the following:
- (void)viewWillAppear:(BOOL)animated
{
_appdelegate.theheurl = currentURL;
NSLog(@"%@", currentURL);
NSLog(@"%@", _appdelegate.theheurl);
[worship loadRequest:[NSURLRequest requestWithURL:currentURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60.0]];
timer = [NSTimer scheduledTimerWithTimeInterval:(1.0/2.0) target:self selector:@selector(tick) userInfo:nil repeats:YES];
[super viewWillAppear:YES];
}
However, both NSLogs in that class come back null. What am I Doing wrong in getting the NSURL from the AppDelegate to the class to load it?