Skip to content

Croissant is a lean downloader queue of raw data in Objective-C

License

Notifications You must be signed in to change notification settings

dvmrmc/Croissant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

test Croissant

This library is a simple queued downloader written in Objective-C and released under MIT License, so feel free to use and PullRequest any bug fix or new behaviour added.

Install

Download the source code, clone it or submodule it. Everything you need is under "Croissant" folder. Drag & Drop it to your project to start working with this tasty code.

Usage

This library provides 2 basic types download. This creates a queue to avoid performance issues when downloading too many resources at the same time.

Configure

  • By setting up the max amount of parallel downloads (5 by default)
[Croissant setMaxDownloads:10];

Download

  • Download raw NSData from either NSURL or NSString
NSURL *url = [NSURL URLWithString:@"<YOUR_RESOURCE_URL_STRING>"];
[Croissant downloadNSDDataFromURL:url
                      cachePolicy:CroissantCachePolicy_NoUseCache
                       completion:^(NSData *data, NSError *error) {
                                    if(error)
                                    {
                                        // Something bad happened with your download
                                    }
                                    else
                                    {
                                        // data is ready
                                    }
                                }];
  • Download an UIImage from either NSURL or NSString
NSURL *url = [NSURL URLWithString:@"<YOUR_RESOURCE_URL_STRING>"];
[Croissant downloadUIImageFromURL:url
                      cachePolicy:CroissantCachePolicy_NoUseCache
                       completion:^(UIImage *image, NSError *error) {
                                    if(error)
                                    {
                                        // Something bad happened with your download
                                    }
                                    else
                                    {
                                        // image is ready
                                    }
                                }];
  • To configure download cache policy, you need to use (CroissantCachePolicy cachePolicy) parameter
    • CroissantCachePolicy_NoUseCache: This forces the download independently of what the cache has in the store (overwriting it in case something is cached)
    • CroissantCachePolicy_UseCache: This returns inmediatly what's stored in the cache in case something is stored.

Author

License

This library is released under MIT License

About

Croissant is a lean downloader queue of raw data in Objective-C

Resources

License

Stars

Watchers

Forks

Packages