UIImage Archives

How to display a UIImage from an NSURL

If you’re displaying images from the main iOS bundle, things are fairly straightforward: self.imageView.image = [UIImage imageNamed:@”Amy.png”]; But if you have an NSURL to your image then it’s not as easy. It took me some digging to find out that you have to convert the URL into NSData first, and then display the data: NSData […]

How to save a UIImage

// let’s save our image as a JPG NSData *imageData = UIImageJPEGRepresentation(chosenImage, 1); // get our home directory and add the save path and file name NSString *imagePath = [NSHomeDirectory() stringByAppendingPathComponent:@”Documents/myImage.jpg”]; // then write the file to disk [imageData writeToFile:imagePath atomically:YES];