title: IPhone Development - Setting Background Image For IPad From A Downloaded Image
body: <p>I am new to this and have searched a lot this week. I am trying to set a background image from a file I have downloaded from a url. I need to save the image for later. Specially if I am not connected to the internet I can still show this image.</p>
  
  <p>I have validated by printing out the contents of the directory that the file exists. This is one of many code that I have tried to make the image appear in the background.</p>
  
  <pre><code>nNSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
  
  NSString *documentPath = [docDir stringByAppendingFormat:@"/mainback.png"];
  
  // If you go to the folder below, you will find those pictures
  
  NSLog(@"%@",documentPath);
  
  
  
  if ([[NSFileManager defaultManager]fileExistsAtPath:documentPath]) {
  
      NSData *data = [NSData dataWithContentsOfFile:documentPath];
  
      UIImage *image = [[UIImage alloc] initWithData:data];
  
      NSLog(@"WHAT - %f,%f",image.size.width,image.size.height);
  
      UIColor *background = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:documentPath]];
  
      self.view.backgroundColor = background;
  
      [background release];
  
  }
  </code></pre>
  
  <p>The code finds the image in the directory but I cannot set the image to the background. Please help.</p>
  
  <p>Thanks</p>