0

i want know if it's possible with the UIDocumentStateChangedNotification detect if an item is deleted, if not, how i can detect if a item is deleted from the cloud?

Piero
  • 9,173
  • 18
  • 90
  • 160

1 Answers1

0

Add an observer for UIDocumentStateChangedNotification to your viewDidLoad.

[[NSNotificationCenter defaultCenter]
        addObserver:self
        selector:@selector(itemHasChanged:)
        name:UIDocumentStateChangedNotification
        object:nil];

If the documentState of a changed object is set to UIDocumentStateSavingError, then it was deleted.

-(void) itemHasChanged:(id)sender {
    UIDocument *itemDoc = [sender object]; 

    if ([itemDoc documentState] == UIDocumentStateSavingError) {
      // your code to handle a deleted document goes here
      // in my case I remove that object from my array of current objects.
    }
}
Peter Johnson
  • 3,764
  • 1
  • 23
  • 27