Cedric 0.2.2

Cedric 0.2.2

Maintained by Stefan.



Cedric 0.2.2

  • By
  • Szymon Mrozek

Carthage compatible Cocoapods Platform Build Status codecov.io License

Cedric

Who am I?

Hey! My name is Cedric, I was born to help iOS / macOS developers with a quite difficult task that is downloading files.

What are my responsibilities?

Behind just downloading files I'm able to perform operations like:

  • notify about updates via MulticastDelegate
  • perform operations in a serial or parallel (with limit) options
  • perform browser-like download with always creating new files
  • reuse already downloaded files for the same resource
  • notify that all resources from queue are downloaded
  • apply attributes to files specified in resource

Example usage

let resource = DownloadResource(id: asset.id, source: asset.url, destinationName: asset.name + ".mp3", mode: .notDownloadIfExists)
try cedric.enqueueDownload(forResource: resource) 

func cedric(_ cedric: Cedric, didFinishDownloadingResource resource: DownloadResource, toFile file: DownloadedFile) {
   do { 
      let url = try file.url()
      guard let image = UIImage(contentsOfFile: url.path) else { return }	
      fileImageView.image = image
   } catch let error {
      ...
   }
}

Cedric Configuration Modes

As I've mentioned, I'm able to work in different modes with allowing for serial or parallel downloading.

Using serial mode (downloading files in the queue one by one):

let configuration = CedricConfiguration(mode: .serial)
return Cedric(configuration: configuration)

Using parallel mode (with concurent 3 tasks):

let configuration = CedricConfiguration(mode: .parallel(max: 3))
return Cedric(configuration: configuration)

Important note By default all files are stored in "Downloads" directory, if you want to store them in different directory please pass it's name to CedricConfiguration object. The same configuration should be passed if you use FileManager.cedricPath(...)

Carthage

Add the following entry in your Cartfile:

github "appunite/Cedric"

Then run carthage update.

Cocoapods

Add the following entry in your Podfile

pod 'Cedric'

Then run pod install.

Contribution

Project is created and maintained by Szymon Mrozek.

We could use your help with reporting or fixing bugs. We would also like to hear from you about feature suggestions. If you have an idea how to make Cedric better you are welcome to send us a Pull Request.

License

Cedric is released under an MIT license. See License.md for more information.