We're making changes to the Community, so you may have received some notifications - thanks for your patience and welcome back. Learn more here.

Forum Discussion

Keith B.7's avatar
Keith B.7
Helpful | Level 7
9 years ago

Obj-C download destination + two questions on method names

Hello again,

 

Three quick questions:

 

1. To download a file, I use -downloadUrl:overwrite:destination:.

 

The documentation for the latter says:

 

"A closure used to compute the destination, given the temporary file location and the response."

 

What exactly does this mean in practice? More specifically: you set a destination URL using the destination parameter, telling the SDK where you want the file downloaded. Then, the response callback provides the final URL. i.e.:

 

NSURL *destinationURL = @"/user/username/documents/file.txt";
        DBDownloadUrlTask *downloadTask = [self.dropboxClient.filesRoutes downloadUrl:@"/my/file.txt" overwrite:YES destination:destinationURL];
        [downloadTask response:^(DBFILESMetadata *metaData, DBFILESDownloadError *downloadError, DBError *dbError, NSURL *downloadURL){
            
        }];

So, my question is: in the above snippet, is downloadURL guaranteed to be the same as destinationURL because I set overwrite to YES? I'm assuming (and hoping) that the final file URL of the downloaded file on disk (downloadURL in the above example) will only ever differ from the destination URL passed into -downloadUrl:... (destinationURL in the above example) if overwrite is set to NO. Is that assumption correct?

 

Then two unimportant questions sprung purely from my curiosity on certain method names:

 

2. What is the significance of the underscore at the end of DBFILESRoutes's "delete" method? That is, why is it "delete_:" instead of "delete:"?

 

3. What is the significance of the "d" prefix of all the copy methods - "dcopy" instead of "copy"?

 

Thanks!

Keith

  • 1. That's correct, since overwrite is NO, destinationURL will be the same as downloadURL. (The documentation is a little misleading due to an old reference to "closure". We'll get that fixed up.)

     

    2. and 3. These methods have these modifications to avoid some reserved keyword/prefix constraints in Objective-C/Cocoa. It's non-ideal of course, but there's nothing special you need to do on your side beyond use those inconsistent names.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    1. That's correct, since overwrite is NO, destinationURL will be the same as downloadURL. (The documentation is a little misleading due to an old reference to "closure". We'll get that fixed up.)

     

    2. and 3. These methods have these modifications to avoid some reserved keyword/prefix constraints in Objective-C/Cocoa. It's non-ideal of course, but there's nothing special you need to do on your side beyond use those inconsistent names.

About Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,875 PostsLatest Activity: 2 years ago
323 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!