title: iOS - Download an HTML web page, search through the content and set text to a label based on query result
body: <p>what I want:</p>
  
  <p>Download a webpage from a server > Save content in a <code>NSString</code> > Search through the content via <code>IsEqualToString</code> > Set text to a label when a specified keyword was found.</p>
  
  <p>I was able to download the webpage, show content in a <code>UITextView</code> but my <code>if</code> function always executes the else part doesn't matter what I'm searching for in <code>IsEqualToString</code>. Please help. </p>
  
  <p>Actually I should see in my label: Course is open and NOT Sorry, course is closed. See screenshot.</p>
  
  <pre><code>//
  //  ViewController.h
  //  TestingHTML2
  //
  //  Created by Marc Woerner on 20.03.12.
  //  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
  //
  
  #import &lt;UIKit/UIKit.h&gt;
  
  @interface ViewController : UIViewController
  {
      NSMutableData *myData;
      NSURLConnection *myConnection;
  }
  
  @property (strong, nonatomic) IBOutlet UITextView *myTextView;
  @property (strong, nonatomic) IBOutlet UILabel *myLabel;
  
  @end
  </code></pre>
  
  <p>ViewController.m</p>
  
  <pre><code>//
  //  ViewController.m
  //  TestingHTML2
  //
  //  Created by Marc Woerner on 20.03.12.
  //  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
  //
  
  #import "ViewController.h"
  
  @interface ViewController ()
  
  @end
  
  @implementation ViewController
  @synthesize myTextView;
  @synthesize myLabel;
  
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
      if (myConnection == nil) {
          myData = [NSMutableData new];
          NSString *urlString = [NSString stringWithFormat:@"http://www.golfplatz-altenstadt.de"];
          myConnection =[NSURLConnection connectionWithRequest:
                        [NSURLRequest requestWithURL:
                        [NSURL URLWithString:urlString]] 
                          delegate:self];
      }
  }
  
  
  
  
  - (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 isEqualToString:@"platz_bespielbar"]) {
          myLabel.text = @"Course is open";
      } else {
          myLabel.text = @"Sorry, course is closed";
      }
  
      myTextView.text = [[NSString alloc] initWithData:myData encoding:NSASCIIStringEncoding];
  
      [self initializeVariablesAgain];
  }
  </code></pre>
  
  <p>When I look through the downloaded web page myself I see an entry:</p>
  
  <blockquote>
    <p>platz_bespielbar</p>
  </blockquote>
  
  <p>So why does my function don't work?</p>
  
  <p><img src="https://i.stack.imgur.com/iVmls.jpg" alt="enter image description here"></p>