We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.

Forum Discussion

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

Obj-C API-2 Equivalent of DBRequest networkRequestDelegate?

Hello,

 

In API-1, I could easily set iOS's activity spinner going whenever Dropbox accessed the network like this:

 

- (BOOL)application:(UIApplication * )application didFinishLaunchingWithOptions:(NSDictionary * )launchOptions
{
    [DBRequest setNetworkRequestDelegate:self];
}

// DBNetworkRequestDelegate - these delegate methods allow us to show and hide the network
// activity spinner in the status bar when Dropbox is doing something.

static NSInteger outstandingDropboxNetworkRequests = 0;
- (void)networkRequestStarted
{
    outstandingDropboxNetworkRequests++;
    if (outstandingDropboxNetworkRequests == 1)
    {
        [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
    }
}
- (void)networkRequestStopped
{
    outstandingDropboxNetworkRequests--;
    if (outstandingDropboxNetworkRequests == 0)
    {
        [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
    }
}

How do I do the same in API 2?

 

Thanks,

Keith

  • Hi Keith, no, the Objective-C SDK doesn't have anything quite like that.

    You should still be able to do effectively the same thing though, by keeping track of the number of outstanding requests, similar to what you already have, by incrementing a counter each time you start a request and decrementing it each response handler.

    We'll consider this a feature request for an easier way to do this though.

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

    Hi Keith, no, the Objective-C SDK doesn't have anything quite like that.

    You should still be able to do effectively the same thing though, by keeping track of the number of outstanding requests, similar to what you already have, by incrementing a counter each time you start a request and decrementing it each response handler.

    We'll consider this a feature request for an easier way to do this though.

    • Keith B.7's avatar
      Keith B.7
      Helpful | Level 7

      Hi Greg,

       

      Thanks for the answer. That's a good idea - following our discussion about cancelling all tasks, I created a "Dropbox task manager" class that I use to invoke all the -response: and -progress: methods for tasks passed into it so that it can keep an array of all running tasks. So I've placed the notifications in there - I should have thought of that myself. :)

       

      Thanks and all the best,
      Keith

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,878 PostsLatest Activity: 8 hours ago
326 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!