iOS dropbox API v2 - 如何获取进度信息?

时间:2017-03-03 13:33:50

标签: ios objective-c dropbox dropbox-api

目前,我正在{@ 3}}之后将Dropbox API集成到我的应用中。一切正常,但我对进度更新感到不满。以下是教程中的示例代码:

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);
}];

在示例代码中,进度处理程序作为参数传递。我之前从未这样做过,也不知道如何运行这个代码(我是obj-C的初学者 - 对不起!)。目前我只是取消注释参数,代码工作正常,但如何获取进度信息?

很抱歉,如果我的问题很简单,但我有点失落......如果有人可以帮助我或指出我正确的方向,那就太好了!谢谢!

1 个答案:

答案 0 :(得分:0)

progress参数占用一个块。您可以在Apple Developer网站here上阅读Objective-C中的块。您可以根据需要在最终的NSLog处理进度更新时添加自己的代码。

相关问题