To start, we are only going to concern ourselves with temporarily storing our pictures in memory. To do this, we can add an image array as a property of our view controller:
class ViewController: UIViewController { var photos = [UIImage]() // ... }
As we saw in the image picker delegate method, UIKit provides a class UIImage
that can represent images. Our photos
property can store an array of these instances. This means that the first step for us is to add new images to our property when the callback is called:
func imagePickerController( picker: UIImagePickerController, didFinishPickingImage image: UIImage!, editingInfo: [NSObject : AnyObject]! ) { self.photos.append(image) self.dismissViewControllerAnimated(true, completion: nil) }
Now every time the user takes or picks a new photo, we add it to our list, which stores all of the images in memory. However, this isn't quite enough, we also...