0

Currently I'm integrating the dropbox API to my app following the tutorial. All works fine but I'm struggeling with the progress update. Here is the sample code from the tutorial:

NSData *fileData = [@"file data example" dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:NO];

[[[client.filesRoutes uploadData:@"/test/path/in/Dropbox/account" inputData:fileData]
setResponseBlock:^(DBFILESFileMetadata *result, DBFILESUploadError *routeError, DBRequestError *error) {
    if (result) {
        NSLog(@"%@\n", result);
    } else {
        NSLog(@"%@\n%@\n", routeError, error);
    }
}] progress:^(int64_t bytesUploaded, int64_t totalBytesUploaded, int64_t totalBytesExpectedToUploaded) {
    NSLog(@"\n%lld\n%lld\n%lld\n", bytesUploaded, totalBytesUploaded, totalBytesExpectedToUploaded);
}];

In the example code the progress handler is passed as an argument. I've never did this before and don't know how to get this code running (I'm a beginner in obj-C - sorry!). Currently I'm just uncommenting the argument and the code works fine but what to do to get the progress information?

Sorry if my question is trivial, but I'm bit lost ... Would be nice if someone can help me or point me in the right direction! THANKS!

Hecot
  • 89
  • 1
  • 11

1 Answers1

0

The progress argument takes a block. You can read up on blocks in Objective-C on the Apple Developer website here. You can add your own code where that final NSLog is to handle progress updates as needed.

Clafou
  • 15,250
  • 7
  • 58
  • 89
  • Thanks for your answer - it turns out that it was a simple typo in the tutorial! It needs to be setProgressBlock - now works like a charm. – Hecot Mar 04 '17 at 19:39