How can I search for a string in a .txt file for NSScanner?

Posted by pixelbitapps on Stack Overflow See other posts from Stack Overflow or by pixelbitapps
Published on 2011-11-30T17:48:45Z Indexed on 2011/11/30 17:50 UTC
Read the original article Hit count: 227

Filed under:
|
|
|
|

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!

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c