title: Why cant I pass this variable from one class to another
body: <p>I am stuck and need some help understanding why this is not working.</p>
  
  <p>I want to be able to download the HTML of a page and then format it to show correctly, the code inside the second class (spriing) will download and display the HTML in a UITextView if it is placed inside the ViewController, however this is breaking the MVC right?</p>
  
  <p>So could anyone tell me why I am getting the out of scope error on the mStringData variable?</p>
  
  <p>My classes are below:</p>
  
  <p>I have one class which is a view controller; </p>
  
  <pre><code>//Class for the download and processing of data from website
  
  #import "FirstViewController.h"
  
  @implementation FirstViewController
  
  // The designated initializer. Override to perform setup that is required before the view is loaded.
  //- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
  //    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
  //        // Custom initialization
  //} 
  //    return self;
  //}
  
  
  /*
  // Implement loadView to create a view hierarchy programmatically, without using a nib.
  - (void)loadView {
  }
  */
  
  // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
  - (void)viewDidLoad {
      [super viewDidLoad];
  
      spriing = [Spriing new];
  
      [spriing downloadData:@"http://www.spriing.co.uk/services/"];
      SpriingTxt.text = spriing.mStringData;
  }
  
  /*
  // Override to allow orientations other than the default portrait orientation.
  - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
      // Return YES for supported orientations
      return (interfaceOrientation == UIInterfaceOrientationPortrait);
  }
  */
  
  - (void)didReceiveMemoryWarning {
      // Releases the view if it doesn't have a superview.
      [super didReceiveMemoryWarning];
  
      // Release any cached data, images, etc that aren't in use.
  }
  
  - (void)viewDidUnload {
      // Release any retained subviews of the main view.
      // e.g. self.myOutlet = nil;
  }
  
  
  - (void)dealloc {
      [super dealloc];
      [mRecData release];
      [mStringData release];
  }
  </code></pre>
  
  <p>And a separate class;</p>
  
  <pre><code>#import "Spriing.h"
  
  @implementation Spriing
  
  @synthesize mStringData;
  @synthesize mRecData;
  
  - (void)downloadData: (NSString*) URL{
  
      mBaseURL = URL;
      // Create the request.
      NSURLRequest *request=[NSURLRequest requestWithURL:[NSURL URLWithString:mBaseURL]
                                          cachePolicy:NSURLRequestUseProtocolCachePolicy
                                          timeoutInterval:60.0];
  
      // create the connection with the request
      // and start loading the data
      mCon=[[NSURLConnection alloc] initWithRequest:request delegate:self];
  
      if (mCon) 
      {
          // create var to store data
          mRecData = [[NSMutableData data] retain];
      } 
      else 
      {
          // Inform the user that the connection failed.
      }
  }
  
  //If the connection is reset
  - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
  {
      [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
      //reset the data length
      [mRecData setLength:0];
  }
  
  //Obtaining new data
  - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
  {
      //Add any newly recieved data to the currently stored data
      [mRecData appendData:data];
  }
  
  //If something went wrong
  - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
  {
      //Release the connection
      [mCon release];
      //Release the data
      [mRecData release];
  
      //Alert the user
      UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Error!" 
                                                       message:@"No internet connection!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease];
      [alert show];
      [alert release];
  }
  
  //When its done
  - (void)connectionDidFinishLoading:(NSURLConnection *)connection
  {
      //NSLog(@"finished");
  
      // Once this method is invoked, "responseData" contains the complete result
      self.mStringData = [[[NSString alloc] initWithData:mRecData encoding:NSUTF8StringEncoding] retain];
  
      //NSLog(@"%@", mStringData);
  
      self.mStringData = [self processData:mStringData];
  
      //NSLog(@"%@", mStringData);
  
      //SpriingTxt.text = mStringData;
  
      [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
  
      //mStringData = nil;
  }
  
  - (NSURLRequest *)connection:(NSURLConnection *)connection
               willSendRequest:(NSURLRequest *)request
              redirectResponse:(NSURLResponse *)redirectResponse
  {
      [mBaseURL autorelease];
      mBaseURL = [[request URL] retain];
      return request;
  }
  
  -(NSString*) processData: (NSString*) string
  {
      NSMutableString *html = [NSMutableString stringWithCapacity:[string length]];
  
      NSScanner *scanner = [NSScanner scannerWithString:string];
  
      NSString *tempText = nil;
  
      while (![scanner isAtEnd])
      {
          [scanner scanUpToString:@"&lt;" intoString:&amp;tempText];
  
          if (tempText != nil)
              [html appendString:tempText];
  
          [scanner scanUpToString:@"&gt;" intoString:NULL];
  
          if (![scanner isAtEnd])
              [scanner setScanLocation:[scanner scanLocation] + 1];
           tempText = nil;
      }
  
      return html;
  }
  
  - (void) dealloc
  {
      [super dealloc];
      //[mStringData release];
  }
  
  @end
  </code></pre>