2013-10-11 40 views

回答

0

將UIDocumentStateChangedNotification的觀察者添加到您的viewDidLoad中。

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

如果更改對象的documentState設置爲UIDocumentStateSavingError,那麼它將被刪除。

-(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. 
    } 
}