Giter Club home page Giter Club logo

dropblocks's Introduction

DropBlocks

Overview

DropBlocks is a wrapper for the Dropbox iOS SDK that lets you use blocks instead of delegate callbacks.

Usage

Instead of making a call like this:

[restClient loadFile:path intoPath:destinationPath];

and then implementing these callbacks:

- (void)restClient:(DBRestClient*)client loadedFile:(NSString*)destPath contentType:(NSString*)contentType metadata:(DBMetadata*)metadata {
	NSLog(@"Yay, my file loaded. Let me go find that progress view so I can dismiss it ...");
}

- (void)restClient:(DBRestClient*)client loadProgress:(CGFloat)progress forFile:(NSString*)destPath {
	NSLog(@"Got some file load progress, let me go find that progress view so I can update it ...");
}

- (void)restClient:(DBRestClient*)client loadFileFailedWithError:(NSError*)error {
	NSLog(@"Uh oh, something went wrong with the file load. Let me go figure out which one that was ...");
}

With DropBlocks you do it all in one place, like so:

UIProgressView* progressView = ... //make me a progressView and present it

[DropBlocks loadFile:path intoPath:intoPath:destinationPath completionBlock:^(NSString* contentType, DBMetadata* metadata, NSError* error) {
	[progressView removeFromSuperview];
	
	if (error) {
		NSLog(@"Uh oh, something went wrong with this file load. I'd better do something about that.");
	} else {
		NSLog(@"Yay, my file loaded. My work here is done.");
	}
} progressBlock:^(CGFloat progress) {
	progressView.progress = progress;
}];

Installation

I highly recommend that you use CocoaPods to integrate DropBlocks into your app. If you aren't familiar with it, CocoaPods is an awesomely simple dependency manager for Objective-C projects. You can get more info about it here.

If you're using CocoaPods, all you have to do is put this line in your Podfile:

pod 'DropBlocks',	'0.0.3'

And you're done. That will also cause the standard Dropbox SDK to be pulled into your project automatically.


If you aren't using CocoaPods (Why not? What's your problem??) then you'll have to just grab the DropBlocks source and drop it into your project. You'll need DropBlocks.m and DropBlocks.h. You'll also have to manually integrate the standard Dropbox SDK into your project. Consult the Dropbox SDK documentation for more information about that.

Setup

You'll need to do all the normal setup for Dropbox in your code (linking account, creating session, etc). You can find information on that in Dropbox SDK documentation.

DropBlocks is meant to be a replacement for all the calls you would normally make to the DBRestClient class.

Caveats

DropBlocks version 0.0.3 is still a beta release, though it is starting to see use in more productions apps. Some of the methods have not been thoroughly tested. Use at your own risk, and please file a bug if you encounter any problems.

Additional Contributors

John Blanco (ZaBlanc) - Fixed file uploading and improved the callback typedefs for better auto-completion. (#1).


Ryan Tsao (rtsao)

  • Fixed progress typedef. (#3)
  • Added progress block to uploadFileChunk. (#6)

Contact

If you end up using DropBlocks in a project, I'd love to hear about it.

email: [email protected]
twitter: @nate_petersen

dropblocks's People

Contributors

jkhowland avatar natep avatar rtsao avatar

Watchers

 avatar

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.