## Introduction
Welcome to the documentation for the `aaloaders` package! This package is designed to provide a set of tools and utilities for loading and managing different types of assets in your iOS and macOS applications. Whether you need to load images, videos, or other types of files, `aaloaders` has got you covered.
## Installation
To get started with `aaloaders`, you will need to install it using CocoaPods. If you’re not familiar with CocoaPods, you can install it by following the instructions on the official CocoaPods website.
“`ruby
pod ‘aaloaders’
“`
After updating your Podfile, run the following command:
“`bash
$ pod install
“`
## Usage
### Loading Images
With `aaloaders`, loading images is made simple. The package provides a `ImageLoader` class that you can use to load images asynchronously, ensuring that your UI remains responsive.
“`swift
import aaloaders
let imageLoader = ImageLoader()
imageLoader.loadImage(from: imageURL) { result in
switch result {
case .success(let image):
// Use the image
case .failure(let error):
// Handle the error
}
}
“`
### Loading Videos
Loading videos with `aaloaders` is as straightforward as loading images. The `VideoLoader` class allows you to load videos asynchronously, making it easy to play videos in your application.
“`swift
import aaloaders
let videoLoader = VideoLoader()
videoLoader.loadVideo(from: videoURL) { result in
switch result {
case .success(let videoURL):
// Use the videoURL
case .failure(let error):
// Handle the error
}
}
“`
## Supported File Types
The `aaloaders` package supports loading various types of assets, including:
– Images (PNG, JPEG, GIF, etc.)
– Videos (MP4, MOV, etc.)
– Audio files (MP3, WAV, etc.)
– XML and JSON files
You can use the respective loaders (`ImageLoader`, `VideoLoader`, etc.) to handle each type accordingly.
## Advanced Configuration
`aaloaders` provides a range of options and configurations to suit your specific needs. You can customize the loaders’ behavior by using the following methods:
### ImageLoader Configuration
To configure the `ImageLoader`, you can use the following methods:
“`swift
imageLoader.setCachePolicy(.useProtocolCachePolicy)
imageLoader.setMaxCacheAge(3600) // in seconds
imageLoader.setSuccessClosure { image in
// Custom success handling
}
imageLoader.setFailureClosure { error in
// Custom failure handling
}
“`
### VideoLoader Configuration
To configure the `VideoLoader`, you can use the following methods:
“`swift
videoLoader.setCachePolicy(.useProtocolCachePolicy)
videoLoader.setMaxCacheAge(3600) // in seconds
videoLoader.setSuccessClosure { url in
// Custom success handling
}
videoLoader.setFailureClosure { error in
// Custom failure handling
}
“`
## Conclusion
With `aaloaders`, you can easily load and manage various types of assets in your iOS and macOS applications. Whether you need to load images, videos, or other types of files, `aaloaders` provides a convenient and reliable solution for asset loading.