title: ASIHTTPRequest working on emulator but not iphone
body: <p>Hey guys I have done lots of work with ASIHTTPRequest so far and use it several times in my ios application, however in one area of my app where I have added another asihttprequest method its not working properly.</p>
  
  <p>First of all it must be said that the reason I'm trying to spread the load of downloading and parsing the data.. If I do this on the subview it takes a good 2-3 second to go through the second xml sheet and get all of the related values out.. where as If I do it on this mainview where people are not seeing anything load etc then when the go back to the subview it should look almost instant. I don't know how correct this is but I figure its a okay thing to do to make the app feel abit snappier.</p>
  
  <p>So I am setting it the asihttprequest methods identically as the other ones that work minus caching.</p>
  
  <p>What happens is I select a table cell from the main view that loads the second view and parses a bunch of info to the tableview. the User then selects a value which is passed back to the main view and displayed. </p>
  
  <p>I then parse another lot of xml data checking the selected valueID against everything in the second xml sheet. so that when the user selects the second cell I pass all the data that was just parsed over to the second view to make it look as though its loaded alot faster.</p>
  
  <p>Heres a flow chart of that will explain what I'm trying to do abit better
  <img src="https://i.stack.imgur.com/6gq07.png" alt="enter image description here"></p>
  
  <p>This is what the parser code looks like in the main view which is the one thats working in the emulator but not on the iphone.</p>
  
  <p>This is my protocol that I call from the subview and pass all the values I need to over and fire off the request to the mainviews ASIHTTPRequest.</p>
  
  <pre><code>    - (void) setManufactureSearchFields:(NSArray *)arrayValues withIndexPath:(NSIndexPath *)myIndexPath
      {
          manufactureSearchObjectString = [[arrayValues valueForKey:@"MANUFACTURER"] objectAtIndex:0];
          manufactureIdString = [[arrayValues valueForKey:@"MANUID"] objectAtIndex:0]; //Restricts Models dataset
          manufactureResultIndexPath = myIndexPath;
          [self.tableView reloadData]; //reloads the tabels so you can see the value in the tableViewCell.
          //need some sort of if statment here so that if the back button is pressed modelSearchObjectString is not changed..
  
          if (oldManufactureSearchObjectString != manufactureSearchObjectString) {
              modelResultIndexPath = NULL;
              modelSearchObjectString = @"empty";
              oldManufactureSearchObjectString = [[NSString alloc] initWithFormat:manufactureSearchObjectString];
          }
  //These two lines below are what execute ASIHTTPRequest and set up my parser etc
          dataSetToParse = @"ICMod"; // This sets the if statment inside parserDidEndDocument
          [self setRequestString:@"ICMod.xml"]; //Sets the urlstring for XML inside setRequestString
  
      }
  </code></pre>
  
  <p>This then fires the ASIHTTPRequest delegate methods.</p>
  
  <pre><code>- (IBAction)setRequestString:(NSString *)string
  {
      //Set database address
      //NSMutableString *databaseURL = [[NSMutableString alloc] initWithString:@"http://127.0.0.1:8888/codeData/"]; // imac development
      NSMutableString *databaseURL = [[NSMutableString alloc] initWithString:@"http://127.0.0.1:8888/codeData/"]; // iphone development
  
      //PHP file name is being set from the parent view
      [databaseURL appendString:string];
  
      NSLog(@"%@", databaseURL);
  
      //call ASIHTTP delegates (Used to connect to database)
      NSURL *url = [NSURL URLWithString:databaseURL];
  
      //This sets up all other request
      ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
  
      [request setDelegate:self];
      [request startAsynchronous];
  
  }
  </code></pre>
  
  <p>When I run this through debug with break points while testing on the iphone this is where the app falls over.. but On the emulator it has no problems.</p>
  
  <p>This next method never gets called when testing on the iphone but workds sweet on the emulator.</p>
  
  <pre><code>- (void)requestFinished:(ASIHTTPRequest *)request
  {   
          responseString = [request responseString]; //Pass requested text from server over to NSString 
          capturedResponseData = [responseString dataUsingEncoding:NSUTF8StringEncoding]; 
  
          [self startTheParsingProcess:capturedResponseData];
  }
  </code></pre>
  
  <p>This is the only other delegate that is fired when testing on the iphone, sends me an alret saying the connection has timed out.</p>
  
  <pre><code>- (void)requestFailed:(ASIHTTPRequest *)request
  {
      NSError *error = [request error];
      NSLog(@"%@", error);
      UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:@"Error!" message:@"A connection failure occurred." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
      [errorAlert show];
  }
  </code></pre>
  
  <p>I don't think you need to see all the parser delegates as I don't think they are the issue as this is where the app falls over...</p>
  
  <p>here is what gets printed to the log... </p>
  
  <pre><code>2011-11-29 14:38:08.348 code[1641:707] http://000.000.000.000:0000/codeData/second.xml
  2011-11-29 14:38:18.470 code[1641:707] Error Domain=ASIHTTPRequestErrorDomain Code=2 "The request timed out" UserInfo=0x1e83a0 {NSLocalizedDescription=The request timed out}
  </code></pre>
  
  <p>If you need more of my code let me know.. but I'm at abit of a loss here as like I say there is no difference to how Im doing this ASIHTTPRequest to other views other than I'm initializing it from the protocol that I'm setting up from the second view.. maybe I should set the values before I reload the table or something... I'm not sure though hopefully someone can help me out with this one and spot the issue I cannot see.</p>