I am writing a Swift app for iOS. I want to know how to get an image from the user's camera roll (or whatever they're calling it these days) and save it locally within the app so that I can reference it later. How would one go about this? As an example, let's say I want to get the image and set it as the image for a UIImageView in my storyboard.
This is exactly what UIImagePickerController
combined with NSUserDefaults
will do.
For you it will be a two part task. First you will have to capture the image with a UIImagePickerController
and then either store it in their photo library, or store it on their device with NSUserDefaults
.
To store an image with NSUserDefaults
, see this question.