同步完成通知(iCLoud)

时间:2013-10-01 09:55:53

标签: ios icloud

如何通知iCloud同步已完成,我怎么知道我有新数据要显示? 例如,应用程序有一些数据。应用程序已被删除并重新安装。当我用openWithCompletionHandler打开文档时,它会在同步完成之前调用我的块。

1 个答案:

答案 0 :(得分:-1)

在viewDidLoad方法中,

//Catch any changes
  NSUbiquitousKeyValueStore *store = [NSUbiquitousKeyValueStore defaultStore];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(storeDidChange:)
                                                 name:NSUbiquitousKeyValueStoreDidChangeExternallyNotification
                                               object:store]; 

    [[NSUbiquitousKeyValueStore defaultStore] synchronize];

实施方法,

- (void)storeDidChange:(NSNotification *)notification
{
    // Retrieve the changes from iCloud
    _notes = [[[NSUbiquitousKeyValueStore defaultStore] arrayForKey:@"AVAILABLE_NOTES"] mutableCopy];
    
}

也查看此链接, http://www.appcoda.com/icloud-programming-ios-intro-tutorial/

相关问题