title: How to load two images in a View in objective c?
body: <p>i am a newbie to objective c and Xcode. I found this code that allows me to load an image into my device from an url and replace it to one i have in the View associated to the class containing this code.. Now i need to load TWO image in the same class, to replace two image that are in the same View... How can i?</p>
  
  <p>EDIT: To be clear: i have a view containing two image view. Each image view display an image contained in a file having a specific name contained in the app resources. Say the first image view contains "image1.jpg" and the second "image2.jpg". What i am trying to do is replace into the device the two image "image1.jpg" and "image2.jpg" with two images taken from the web (for the sake of an update of some app images to be done eventually during the app life trought the use of an xml, and so on).</p>
  
  <pre><code>- (void)loadImgFromURLString: (NSString *)theUrlString{
      NSLog(@"Downloading image...");
      backgroundHome.image = nil;    
  
      NSURLRequest *request = [NSURLRequest requestWithURL:
                          [NSURL URLWithString:theUrlString]
                           cachePolicy:NSURLRequestReturnCacheDataElseLoad
                          timeoutInterval:30.0];
      connection = [[NSURLConnection alloc]
                initWithRequest:request delegate:self];
   }
  
   - (void)connection:(NSURLConnection *)theConnection
       didReceiveData:(NSData *)incrementalData {
      if (data == nil)
          data = [[NSMutableData alloc] initWithCapacity:2048];
  
      [data appendData:incrementalData];
   }
  
  - (void)connectionDidFinishLoading:(NSURLConnection *)theConnection{
      backgroundHome.image = [UIImage imageWithData:data];
      NSLog(@"Image ready...");
  
      // save image in document dir
      NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
      NSString *pngFilePath = [NSString stringWithFormat:@"%@/test.png",docDir];
      [data writeToFile:pngFilePath atomically:YES];
  }
  </code></pre>