tcblobdownloadswift

Introduction

Welcome to the documentation for TCBlobDownloadSwift, a powerful Swift library for handling file downloads with ease. This documentation will guide you through the installation process, usage, and provide examples for integrating TCBlobDownloadSwift into your projects.

Installation

Requirements

  • Swift 5.0 or later
  • iOS 10.0 or later

Installation via CocoaPods

To install TCBlobDownloadSwift using CocoaPods, add the following line to your Podfile:

pod 'TCBlobDownloadSwift'

Then, run pod install to retrieve the dependencies.

Manual Installation

  1. Download the TCBlobDownloadSwift framework from the official GitHub repository.
  2. Drag and drop the framework into your Xcode project.
  3. Ensure that the framework is added to your project’s target.

Usage

To begin using TCBlobDownloadSwift, follow the steps below:

Importing the Framework

In your Swift file, import the TCBlobDownloadSwift framework:

import TCBlobDownloadSwift

Initializing a Download Manager

Create an instance of TCBlobDownloadManager to handle file downloads:

let downloadManager = TCBlobDownloadManager()

Starting a Download

To start a download, call the downloadFileAtURL method on the download manager instance:

let downloadTask = downloadManager.downloadFile(atRemoteURL: URL(string: "YOUR_DOWNLOAD_URL")!, to: URL(string: "YOUR_DESTINATION_PATH")!)

Monitoring Download Progress

You can monitor the progress of a download using the TCBlobDownloadDelegate protocol. Conform to the protocol, implement the required methods, and set the delegate:

class YourViewController: UIViewController, TCBlobDownloadDelegate {
// ...
}

Inside your view controller, set the delegate to monitor download progress:

downloadTask.delegate = self

Implementing TCBlobDownloadDelegate Methods

Implement the downloadProgress method to receive updates on the download progress:

func downloadProgress(_ download: TCBlobDownload, didProgress progress: Float, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64) {
// Handle progress updates
}

Examples

Here are a few examples showcasing common use cases when using TCBlobDownloadSwift:

Downloading a File and Saving to Documents Directory

This example shows how to download a file and save it to the Documents directory of the app:

let downloadTask = downloadManager.downloadFile(atRemoteURL: URL(string: "YOUR_DOWNLOAD_URL")!, to: FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0])

Pausing and Resuming a Download

You can pause or resume a download task using the provided methods:

downloadTask.pause()
downloadTask.resume()

Conclusion

Congratulations! You have successfully installed TCBlobDownloadSwift and can now start integrating file download functionality into your iOS projects. For more advanced features and options, please refer to the official GitHub repository and explore the library’s documentation and source code.