title: Objective C, base64 png to UIImage
body: <p>I'm trying to convert a data:image/png;base64 to an UIImage, then get a CGImage and from the UIImage and send it to a Zebra printer. </p>
  
  <p>I try this code:</p>
  
  <pre><code>NSData *datad = [[NSData alloc] initWithData:[NSData dataFromBase64String:@"data:image/png;base64,iVBORw0KGgoAAAANS...etc"]];
  UIImage *image = [UIImage imageWithData:datad];
  [image CGIamge]
  </code></pre>
  
  <p>And i'm trying with this code:</p>
  
  <pre><code>NSString *base64Url = @"data:image/png;base64,iVBORw0KGgoAAAANS...etc";
  NSURL *url = [NSURL URLWithString:base64Url];
  NSString *base64Image = [NSString stringWithContentsOfURL:url];
  url = [NSURL URLWithString:base64Image];
  NSData *rawImageData = [NSData dataWithContentsOfURL:url];
  UIImage *image = [UIImage imageWithData:rawImageData];
  </code></pre>
  
  <p>With the second part of the code i get a black image. </p>
  
  <p>I'm doing something wrong for sure.</p>
  
  <p>I'm also try to do this <a href="https://stackoverflow.com/questions/24898125/how-to-create-cgimageref-from-nsdata-string-data-not-uiimage">How to create CGImageRef from NSData string data (NOT UIImage)</a></p>
  
  <p>aaaaand nothing.</p>
  
  <p>Please, if someone could help me, you will be my heroe!</p>