cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Back again with another edition of 'How we use Dropbox', so find out how Emma uses to-do lists to get it all done here!

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Obj-C API-2 Equivalent of DBRequest networkRequestDelegate?

Obj-C API-2 Equivalent of DBRequest networkRequestDelegate?

Keith B.7
Helpful | Level 7

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

1 Accepted Solution

Accepted Solutions

Re: Obj-C API-2 Equivalent of DBRequest networkRequestDelegate?

Greg-DB
Dropboxer

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.

View solution in original post

2 Replies 2

Re: Obj-C API-2 Equivalent of DBRequest networkRequestDelegate?

Greg-DB
Dropboxer

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.

View solution in original post

Re: Obj-C API-2 Equivalent of DBRequest networkRequestDelegate?

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

Poll
We love to learn from the educators who use Dropbox. Whether you teach kids, teens, adults or a combination of all three, we want to know what apps and integrations you use with Dropbox to help with teaching. Which of the ones below is your favorite, or most used tool?
Who's talking

Top contributors to this post

  • User avatar
    Keith B.7 Helpful | Level 7
  • User avatar
    Greg-DB Dropboxer
What do Dropbox user levels mean?
Need more support?