title: Convert UIImage to NSData and save with core data
body: <p>I have a <code>UIImageView</code> whose image gets set via <code>UIImagePicker</code></p>
  
  <pre><code>- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
      [picker dismissViewControllerAnimated:YES completion:nil];
      self.gImage.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
  }
  </code></pre>
  
  <p>I "attempt" to convert this image to <code>NSData</code> and save it with core data:</p>
  
  <pre><code>NSData *imageData = UIImagePNGRepresentation(self.gImage.image);
  NSString *savedData = [[NSString alloc]initWithData:imageData encoding:NSUTF8StringEncoding];
  
  //am is a pointer to my entities class. imageData is just a NSString attribute
  am.imageData = savedData;
  
  NSError *error;
  if (![self.managedObjectContext save:&amp;error]) {
      //Handle Error
  } else {
      [self dismissViewControllerAnimated:YES completion:nil];
  }
  </code></pre>
  
  <p>Then I try to load the image in a separate file:</p>
  
  <pre><code>self.cell.gImage.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:self.myEntity.imageData]]];
  </code></pre>
  
  <p>I cannot see why this is not working. Any help is greatly appreciated!</p>