How can I search for a string in a .txt file for NSScanner?
- by pixelbitapps
I currently have the following code to get a certain piece of code from the UIWebView:
NSURL *requestTimetableURL = [NSURL URLWithString:@"http://www.dhsb.org/index.phtml?d=201435"];
NSLog(@"Loaded Timetable");
NSError *error;
NSString *page = [NSString stringWithContentsOfURL:requestTimetableURL
encoding:NSASCIIStringEncoding
error:&error];
[webView loadHTMLString:page baseURL:requestTimetableURL];
NSString* Period1;
NSScanner *htmlScanner = [NSScanner scannerWithString:page];
[htmlScanner scanUpToString:@"<P align=center><STRONG><FONT color=#c00000>" intoString:NULL];
[htmlScanner scanString:@"<P align=center><STRONG><FONT color=#c00000>" intoString:NULL];
[htmlScanner scanUpToString:@"</FONT>" intoString:&Period1];
How can I scan a .txt file (which contains the string like above) for the code?
E.G. [htmlScanner scanUpToString:teststring intoString:NULL];
Thanks!