Im trying to download HTML in my IOS app, and once i get the html into my app, i want to search the downloaded data and print the text between two values. Example: if i get this data from my html data: content-START the dogs want to do things that do stuff STOP
i want to print the text between START and STOP in a UITextView so people can view the text cleanly. is there any way to do this? Code i have so far:
@implementation FirstViewController
//http://www.streakadvice.com/path-to-the-stash-luke.html
- (void)viewDidLoad{
[super viewDidLoad];
if (myConnection == nil) {
myData = [NSMutableData new];
NSString *urlString = [NSString stringWithFormat:@"http://www.streakadvice.com/path-to-the-stash-luke.html"];
myConnection = [NSURLConnection connectionWithRequest:
[NSURLRequest requestWithURL:
[NSURL URLWithString:urlString]]
delegate:self];
}
[self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"SFTCBR3.png"]]];
NSString *fullURL = @"http://www.streakadvice.com/path-to-the-stash-luke.html";
NSURL *url = [NSURL URLWithString:fullURL];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[myData appendData:data];
}
-(void)initializeVariablesAgain {
myData = nil;
myConnection = nil;
myTextView = nil;
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSString *stringToLookup = [[NSString alloc]initWithData:myData encoding:NSASCIIStringEncoding];
if ([stringToLookup rangeOfString:@"Start"].location != NSNotFound) {
myLabel.text = @" ";
} else {
myLabel.text = @" ";
}
myTextView.text = [[NSString alloc] initWithData:myData encoding:NSASCIIStringEncoding];
[self initializeVariablesAgain];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end