0
我想知道是否可以用UIDocumentStateChangedNotification
检测项目是否被删除,如果没有,我如何检测项目是否从云中删除?UIDocumentStateChangedNotification detect删除项目
我想知道是否可以用UIDocumentStateChangedNotification
检测项目是否被删除,如果没有,我如何检测项目是否从云中删除?UIDocumentStateChangedNotification detect删除项目
将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.
}
}