Introduction
Welcome to the documentation for the TCBlobDownload framework!
About
The TCBlobDownload framework is a powerful library that provides an easy way to download files asynchronously in iOS apps. With its simple API, you can effortlessly handle file downloads in the background, monitor progress, and handle errors efficiently.
Installation
To install TCBlobDownload in your project, follow these steps:
- Open your project in Xcode.
- Go to the File menu and select Swift Packages and then Add Package Dependency.
- In the search bar, enter
https://github.com/thibaultCha/TCBlobDownload.git
and click Next. - Select the package when it appears and click Next.
- Choose the version rule you want to use and click Next.
- Finally, click Finish to complete the installation process.
Usage
Using TCBlobDownload is straightforward. Just follow these steps:
- Import the framework in your file:
- Create an instance of TCBlobDownloader:
- Implement the delegate methods to handle download events:
- Start the download:
import TCBlobDownload
let downloader = TCBlobDownloader(url: URL(string: "https://example.com/fileToDownload")!, delegate: self)
extension YourViewController: TCBlobDownloadDelegate {
func download(_ download: TCBlobDownload, didProgress progress: Float, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64) {
// Handle download progress updates
}
func download(_ download: TCBlobDownload, didFinishWithError error: Error?, atLocation location: URL?) {
if let error = error {
// Handle any download errors
}
else {
// Handle successful download
}
}
}
downloader.start()
Additional Features
TCBlobDownload offers several additional features to enhance your download functionality, such as:
- Pause and resume downloads
- Cancel ongoing downloads
- Change the maximum number of simultaneous downloads
- Customize download request parameters
These features can be accessed through the TCBlobDownload delegate methods and the TCBlobDownloader instance methods.
Examples
Here are some examples to demonstrate the usage of TCBlobDownload:
Example: Basic File Download
let downloader = TCBlobDownloader(url: URL(string: "https://example.com/fileToDownload")!, delegate: self)
downloader.start()
Example: Pause and Resume
func pauseDownload() {
downloader.pause()
}
func resumeDownload() {
downloader.resume()
}
Example: Cancel Download
func cancelDownload() {
downloader.cancel()
}
Conclusion
Congratulations! You now have the knowledge to integrate TCBlobDownload into your iOS app and provide seamless file downloading capabilities.
If you have any further questions or need assistance, please refer to the official GitHub repository for this project.