In some reasons, you might want to store an UIImage, that is generated using Core Graphics, or from device’s Photo Gallery via UIImagePickerController, to a local file as PNG or a JPEG format.
By using UIImagePNGRepresentation() or UIImageJPEGRepresentation(), UIImage will be converted into Data so you can write it to local file easily.