Objective c 如何从已知url/文件路径检索UIManagedDocument?

Objective c 如何从已知url/文件路径检索UIManagedDocument?,objective-c,url,uimanageddocument,Objective C,Url,Uimanageddocument,我的目的是从已知url检索UIManagedDocument对象,然后打开它 比如: UImanagedDocument *doc = retrieveDoc(url); [doc openWithCompletionHandler:^(BOOL success){ ....}]; 然后,我可以做一些类似的事情: UImanagedDocument *doc = retrieveDoc(url); [doc openWithCompletionHandler:^(BOOL succ

我的目的是从已知url检索UIManagedDocument对象,然后打开它

比如:

 UImanagedDocument *doc = retrieveDoc(url);
 [doc openWithCompletionHandler:^(BOOL success){ ....}];
然后,我可以做一些类似的事情:

 UImanagedDocument *doc = retrieveDoc(url);
 [doc openWithCompletionHandler:^(BOOL success){ ....}];
相信我,我确实搜索过苹果的文档,只有一种方法叫做使用给定url初始化。是的,我先创建并保存它,然后我只需要拿起它。有办法吗


希望任何人都能给出提示,谢谢,应该有这样的类方法,但是在apple的参考中,我找到了创建UIManagedDocument的示例代码

 doc = [[UIManagedDocument alloc] initWithFileURL:docURL];
 if ([[NSFileManager defaultManager] fileExistsAtPath:[docURL path]]) {
[doc openWithCompletionHandler:^(BOOL success){
    if (!success) {
        // Handle the error.
    }
}];
}
else {
[self addInitialData];
[doc saveToURL:docURL forSaveOperation:UIDocumentSaveForCreating completionHandler:^(BOOL success){
    if (!success) {
        // Handle the error.
    }
}];
所以,基本上,每次我想从给定的url检索UIManagedDocument时,我必须先初始化它,然后再打开它。我说得对吗


不管怎样,这就是我发现到目前为止的工作方式。

例如:-BOOLreadFromURL:NSURL*url错误:NSError**outError这应该是一个类方法吗?那就是我想要的。。。