PlantAssetsPickerViewController

class PlantAssetsPickerViewController : AssetsPickerViewController, AssetsPickerViewControllerDelegate

The controller for picking images from the user’s library.

  • A manager of the images selected and de-selected. It ensures that the selected images are requested and written to disk.

    Declaration

    Swift

    var assetTracker: AssetIndexIDTracker
  • Plant object to select images for.

    Declaration

    Swift

    var plant: Plant!
  • Delegate that gets called when the user is done selecting images.

    Declaration

    Swift

    var didFinishDelegate: AssetPickerFinishedSelectingDelegate?
  • Options for fetching images from the user’s library. This controller only requests images.

    Todo

    make private

    Declaration

    Swift

    let fetchOptions: PHFetchOptions
  • A manager required for getting images from a user’s library.

    Todo

    make private

    Declaration

    Swift

    let imageManager: PHImageManager
  • Options for the images requested from a user’s library.

    Todo

    make private

    Declaration

    Swift

    let imageOptions: PHImageRequestOptions
  • Todo

    can I get rid of this and replace it with an init() that calls this with nil values?

    Declaration

    Swift

    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?)
  • Undocumented

    Declaration

    Swift

    convenience init()
  • Undocumented

    Declaration

    Swift

    required init?(coder aDecoder: NSCoder)
  • Log if the controller cannot get access to the photos library.

    Declaration

    Swift

    func assetsPickerCannotAccessPhotoLibrary(controller: AssetsPickerViewController)
  • Set up the image picker. This is called upon initialization and need only be called once.

    Todo

    make private

    Declaration

    Swift

    func setup()
  • Called when the user selects an image. The full image is requested and saved to the plant’s images.

    Important

    The fullfillment of the asset request is done asynchronously by imageManager. The request returns a task ID. This ID is saved to the assetTracker and used to connect the users selection with the final UIImage. The index of the selection is also stored so that the image can be deleted if the user deselects the image.

    Declaration

    Swift

    func assetsPicker(controller: AssetsPickerViewController, didSelect asset: PHAsset, at indexPath: IndexPath)

    Parameters

    controller

    The AssetsPickerViewController that is being used to select images.

    asset

    The asset (image) seleted by the user to be requested.

    indexPath

    The index location of the asset.

  • Called when the user deselects an image.

    Important

    The assetTracker is used to ensure that the image selected is deleted and removed from the plant’s array of image file names.

    Declaration

    Swift

    func assetsPicker(controller: AssetsPickerViewController, didDeselect asset: PHAsset, at indexPath: IndexPath)

    Parameters

    controller

    The AssetsPickerViewController that is being used to select images.

    asset

    The asset (image) deseleted by the user.

    indexPath

    The index location of the asset.

  • Called when the user is done editing and wants to save their selections.

    All images should have already been saved, but this is double checked.

    Declaration

    Swift

    func assetsPicker(controller: AssetsPickerViewController, selected assets: [PHAsset])

    Parameters

    controller

    The AssetsPickerViewController that is being used to select images.

    assets

    All of the assets (images) selected by the user.

  • Called when the user canels their image picker session. The assetTracker is used to ensre that all images previously saved are deleted.

    Declaration

    Swift

    func assetsPickerDidCancel(controller: AssetsPickerViewController)

    Parameters

    controller

    The AssetsPickerViewController that is being used to select images.

  • Write a UIImage to disk as a JPEG and save the UUID to the plant’s array of images.

    Note

    The images are saved in a background thread using GCD.

    Declaration

    Swift

    func addImageToPlant(image: UIImage?, info: [AnyHashable : Any]?)

    Parameters

    image

    The image to write to disk (as a JPEG)

    info

    Information about the image returned when the asset was fetched from the user’s library. This information contains the tracking ID which is then linked to the images UUID in the assetTracker.