iOSPadawan
iOSPadawan

Reputation: 146

Dropbox API usage for DBSyncStatus active

I'm making my way through Learning Core Data for iOS and I've found the Dropbox API has been updated since the book went to press less than a year ago.

In the book, there's this method:

- (void)refreshStatus
{
    DBAccount *account = [[DBAccountManager sharedManager] linkedAccount];
    if (!account.isLinked) {
        self.navigationItem.title = @"Unlinked";
    } else if ([[DBFilesystem sharedFilesystem] status] > DBSyncStatusActive) {
        self.navigationItem.title = @"Syncing";
    } else {
        self.navigationItem.title = @"Backups";
    }
}

I looked through the headers for the current Dropbox framework and there's no "DBSyncStatusActive", but there is a header called "DBSyncStatus" with a BOOL for the active property of DBSyncStatus. What would I type in to get a BOOL that returns the DBSyncStatus.

Here's a link to the documentation, but I'm not clear on what I need to do to get a BOOL to return: https://www.dropbox.com/developers/sync/docs/ios#DBSyncStatus

Upvotes: 0

Views: 124

Answers (2)

J-Q
J-Q

Reputation: 372

@property (nonatomic, readonly) BOOL active;

should be your replacement, which is specifically about Sync Status Activity.I have tried it out, it works great.

- (void)refreshStatus {
        DBAccount *account = [[DBAccountManager sharedManager] linkedAccount];

        if (!account.isLinked) {
            self.navigationItem.title = @"Unlinked";
        } else if ([[DBFilesystem sharedFilesystem] status].active) {
            self.navigationItem.title = @"Syncing";
        }
        else {
            self.navigationItem.title = @"Backups";
        }

    }

Here is why:

@interface DBSyncStatus : NSObject

/** Background synchronization is actively processing or waiting for changes. Syncing is active when a is first created until it completes its first file info sync. After that point it is active whenever there are changes to download or upload, or when there are any files open or path observers registered. */

@property (nonatomic, readonly) BOOL active;

Upvotes: 0

rmaddy
rmaddy

Reputation: 318954

The new 3.0.x version of the Sync/Datastore API that came out recently changed how this is done.

What you have is difficult to translate since it is hard to tell what you are looking for.

The new status can tell if there is any uploading or downloading going on or if there is any meta data being synced.

If all your really care about is if anything is happening then you can do:

} else if ([DBFilesystem sharedFilesystem].status.anyInProgress) {

This will be true if there is any meta data sync, any uploading, or any downloading going on with the file system.

Upvotes: 2

Related Questions