Coder Social home page Coder Social logo

cedric's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.