Skip to content

Written in Swift, Cheapjack is a download manager providing an interface over NSURLSessionDownloadTask for managing multiple, simultaneous downloads with easier control over resuming, etc.

License

Gurpartap/Cheapjack

Repository files navigation

Cheapjack

Carthage compatible License

A drop-in framework for adding a background download manager to your iOS app.

CheapjackExample project, as pictured above, demonstrates downloading multiple files and displaying their states in a custom UITableViewCell.

For advanced usage and control over downloads refer to definitions in Cheapjack.swift.

Usage

Cheapjack's pretty simple to use.

class MyDownloadManager {
	class func prepareForDownload() {
		Cheapjack.downloadCompletionHandler = { (download, session, location) -> NSURL? in
			// Return NSURL of location to move the file to once the download completes.
			// Or do it manually and return nil.
			return nil
		}
	}

	func downloadFile() {
		MyDownloadManager.prepareForDownload()

		let url = NSURL("https://support.apple.com/library/APPLE/APPLECARE_ALLGEOS/HT1425/sample_iPod.m4v.zip") // 2.2 MB
		Cheapjack.downloadWithURL(url, delegate: self)
	}
}

In your app delegate implementation:

func application(application: UIApplication, handleEventsForBackgroundURLSession identifier: String, completionHandler: () -> Void) {
	MyDownloadManager.prepareForDownload()
	Cheapjack.backgroundSessionCompletionHandler = completionHandler
}

For download states and progress reporting, see Cheapjack.swift public methods and the full featured implementation in the included example project.

Requirements

  • iOS 8.1 SDK+
  • Xcode 7+

Install with Carthage

Add the following to your Cartfile:

github "Gurpartap/Cheapjack"

Run carthage update --platform iOS and follow the adding framework instructions in Carthage's README.

Manual Installation

git clone https://github.com/Gurpartap/Cheapjack.git
cd Cheapjack
  1. Add Cheapjack.xcodeproj to your Xcode project or workspace.
  2. Add Cheapjack.framework to Linked Frameworks and Libraries in your app's target.
  3. Create a New Copy Files Phase with Frameworks as the Destination in the target's Build Phases.
  4. Add Cheapjack.framework to this Copy Files build phase.
  5. Try import Cheapjack in your code. Build should succeeed.

Contact

About

Written in Swift, Cheapjack is a download manager providing an interface over NSURLSessionDownloadTask for managing multiple, simultaneous downloads with easier control over resuming, etc.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published