Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
ekantrowitz
10 years agoNew member | Level 2
objective-c API v2 - getMetaData Problem with Block response
I am converting to objective C API v2. I wrote this route to verify if a file is in a dropbox directory called DA. I get on the NSLog that the file exits, but the BOOL return value of the function is always 0. Any help would be appreciated.
- (BOOL)verifyFileInDropboxWith:(NSString *)fileName {
__block BOOL fileOnDB = NO;
NSString *dBFilePath = [NSString stringWithFormat:@"/DA/%@",fileName];
DropboxClient *client = [DropboxClientsManager authorizedClient];
[[client.filesRoutes getMetadata:dBFilePath]
response:^(DBFILESMetadata *result, DBFILESGetMetadataError *routeError, DBError *error){
if([result.name containsString:fileName])
{
NSLog(@"File already exists DB");
fileOnDB = YES;
} else {
NSLog(@"File does not exist in DB");
fileOnDB = NO;
}
}];
return (fileOnDB);
}2 Replies
- mrschulz9 years agoExplorer | Level 3
Your function does this
set return value to NO
call a block ( which takes some time, asynchronously )
immediately return the return value
The block will not set it to another value until it's done the dropbox API call.
- Greg-DB9 years ago
Dropbox Community Moderator
Mrschulz's comment is correct, the response block is asynchronous. The result of the API call is only returned in the response block, so you should trigger whatever is relying on that value inside the response block.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
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, Facebook or Instagram.
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!