DownloadActivityTrackable

@objc public protocol DownloadActivityTrackable

Make UITableViewCell coordinate with DownloadListController to:

  1. track download activity;
  2. handle button touch event;
  3. update button’s title or image.

All properties and methods in the protocol are optional. I have made UITableViewCell conform to this protocol in extension and don’t implement any property or method.

  • Update content of detailTextLabel. DownloadTrackerCell use it to displays download progress info. This method will be called in necessary place if cell implement this method.

    Declaration

    Swift

    @objc optional func updateDetailInfo(_ info: String?)

    Parameters

    info

    A string describing download detail, e.g., 10 KB/117 MB.

  • Update download speed info. DownloadTrackerCell add a UILabel at the right of contentView to display speed info. This method will be called in necessary place if cell implement this method.

    Declaration

    Swift

    @objc optional func updateSpeedInfo(_ info: String?)

    Parameters

    info

    A string describing download speed, e.g., 10 KB/s. If task is not downloading any more, this value is nil.

  • Update download progress. DownloadTrackerCell add a UIProgressView at bottom of contentView to display progress. This method will be called in necessary place if cell implement this method.

    Declaration

    Swift

    @objc optional func updateProgressValue(_ progress: Float)

    Parameters

    progress

    Usually its range is 0.0…1.0, and it’s -1 if progress is unknown.

  • Update accessoryButton’s enabled and image. In DownloadListController, when its cellAccessoryButtonStyle == .icon, this method will be called in necessary place if cell implement this method.

    Declaration

    Swift

    @objc optional func updateAccessoryButtonState(_ enabled: Bool, image: UIImage?)

    Parameters

    enabled

    Enable button or not.

    image

    Button image.

  • Update accessoryButton’s enabled and title. In DownloadListController, when its cellAccessoryButtonStyle == .title, this method will be called in necessary place if cell implement this method.

    Declaration

    Swift

    @objc optional func updateAccessoryButtonState(_ enabled: Bool, title: String)

    Parameters

    enabled

    Enable button or not.

    title

    Button title.