applicationDidFinishLaunching: method.
[DropIO setAPIKey:@"...yourAPIKeyHere..."];
NSError* error = nil;
DropIODrop* addedDrop = [DropIO findDropNamed:@"myDrop"
withToken:@"yourTokenHere"
error:&error];
DropIODrop* newDrop = [DropIO dropWithName:@"myNewDrop"
andPassword:@"mySuperSecretPassword"];
NSError* error = [DropIO lastError];
kDropIOErrorAction,
kDropIOErrorMessage, and/or kDropIOErrorResult key constants to access the error
values returned from drop.io in the NSError.userInfo dictionary, like so:
if (error != nil)
{
NSString* msg = [[error userInfo] objectForKey:kDropIOErrorMessage];
NSString* action = [[error userInfo] objectForKey:kDropIOErrorAction];
NSString* result = [[error userInfo] objectForKey:kDropIOErrorResult];
NSString* desc = [error localizedDescription];
// Use error strings here...
}
, like so:
[myDrop loadAllAssets];
* Note that in DropKit 1.1 you must first check to see if the drop is small enough to load all the assets.
Some drops may contain thousands of assets and thus loading all assets is not an option. Call the new method
[DropIODrop canLoadAllAssets] to check if loading all assets is feasible.
If you cannot load all assets at once, call [DropIODrop loadAssetPages:] instead, passing a
Cocoa NSIndexSet object as the parameter. In the drop.io API, assets are loaded from a drop in "pages". Currently
the API defines a "page" as a set of 30 assets. An NSIndexSet object specifies the first and last page index to
load into memory.
To determine the number of pages in a drop, call [DropIODrop lastAssetPageIndex].
- To get a reference to a specific asset in the drop, call
[DropIODrop findAssetNamed:loadIfMissing:], like so:
DropIOImage* asset = (DropIOImage*)[myDrop findAssetNamed:@"My Portrait" loadIfMissing:YES];
if (asset == nil)
{
NSError* error = [DropIO lastError];
// Handle error here...
}
// Use asset here...
* Again in DropKit 1.1 this method is deprecated in favor of the new method [DropIODrop findAssetNamed:inAssetPages:loadIfMissing]
which lets you specify a range of asset pages over which to search using an NSIndexSet, instead of loading all assets.
- To create a new asset on the drop, you must call one of the DropIODrop asset creation methods
listed below.
- (DropIONote*)noteWithTitle:(NSString*)noteTitle
contents:(NSString*)text;
- (DropIOLink*)linkWithTitle:(NSString*)linkTitle
url:(NSURL*)linkURL
description:(NSString*)linkDesc;
- (DropIODocument*)docWithFilename:(NSString*)fileName
data:(NSData*)docData
mimeType:(NSString*)docMimeType;
- (DropIOImage*)imageWithName:(NSString*)imgName
data:(NSData*)imgData
format:(NSString*)imgDataFormat;
The docWithFilename... method can be used to upload any type of file to drop.io.
For movie and audio files, you may simply typecast the returned object to either
a DropIOMovie or DropIOAudio object.
The DropKit source code is released as open-source software under the terms of the Apache License 2.0.
I work a day job as a Java developer. Writing software for the iPhone is my passion and a second job for me, for which I am currently getting paid very little. DropKit is an attempt to generate some extra revenue for me and my family.
Please consider making a donation if you have found DropKit useful in any way, whether you are using it in your own projects, or if you just browsed my code for help with some other problem you may be having. Your payments help me to gauge the level of interest in this project, and encourage further support and development.
I have set up a PayPal account to accept payments. Just click the link below... and if you have already donated, thank you very much!
-- Chris Patterson, DropKit author
1.5.8