2013-06-05 28 views
1

我正在使用Dropbox在我的應用程序中同步文件。當試圖將帳戶與Dropbox斷開鏈接時,使用以下語句:在iOS中取消帳戶與Dropbox的連接

[[[[DBAccountManager sharedManager] linkedAccount] unlink]; iPhone 4S需要1秒左右,模擬器稍長一點,3GS相當長,但對於iPhone 5來說,它看起來好像根本不工作!這可能是一個記憶問題嗎?我在這裏錯過了什麼嗎?

感謝您的建議!

伊桑

回答

2

從保管箱forum。只有在syncinc /下載完成後,取消鏈接才能完成。

使用GCD適合我。

- (void)dropboxLogout { 
    self.isLogingOut = YES; 
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ 
     [[[DBAccountManager sharedManager] linkedAccount] unlink]; 
     self.isLogingOut = NO; 
    }); 
} 

我使用isLogingOut標誌,以防止我的應用程序從進一步與Dropbox的API進行通信,同時取消鏈接正在進行中。

+0

偉大的工作:)有用 – Bala

+0

的一個問題是爲iPhone 5的取消鏈接仍然沒有發生......這是一個iPhone 5的問題? –

0

我使用基於最新的Dropbox SDK驗證碼:

- (IBAction)unlinkDropbox:(UIButton *)sender { 
    DBAccount *account = [[DBAccountManager sharedManager] linkedAccount]; 
    if (account) { 
     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ 
      [account unlink]; 
      // Shutdown and stop listening for changes to the datastores 
      [[DBDatastoreManager sharedManager] shutDown]; 
      [[DBDatastoreManager sharedManager] removeObserver:self]; 

      // Use local datastores 
      [DBDatastoreManager setSharedManager:[DBDatastoreManager localManagerForAccountManager:[DBAccountManager sharedManager]]]; 
     }); 
     self.isLinked = NO; 
    } 
相關問題