В настоящее время я определяю каталог документов и извлекаю URL-адреса внутри, сохраняя свойство массива:
// Returns an array of all the Vacations on file.
- (void)findVacationsOnFile
{
self.vacationURLs = [[NSArray alloc] init];
// Identify the documents folder URL.
NSFileManager *fileManager = [[NSFileManager alloc] init];
NSError *errorForURLs = nil;
NSURL *documentsURL = [fileManager URLForDirectory:NSDocumentDirectory
inDomain:NSUserDomainMask
appropriateForURL:nil
create:NO
error:&errorForURLs];
if (documentsURL == nil) {
NSLog(@"Could not access documents directory\n%@", [errorForURLs localizedDescription]);
} else {
// Retrieve the vacation stores on file.
NSArray *keys = [NSArray arrayWithObjects:NSURLLocalizedNameKey, nil];
self.vacationURLs = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:documentsURL
includingPropertiesForKeys:keys
options:NSDirectoryEnumerationSkipsHiddenFiles
error:nil];
}
}
Когда мне впоследствии нужен URL-адрес для UIMagedDocument, я ссылаюсь на массив. Но я подозреваю, что UIManagedDocument уже знает свой URL. Самое близкое, что я нашел к этому, — это persistStoreName, но это метод, используемый для установки имени постоянного хранилища. Любое руководство приветствуется.