我有一个目录的安全范围书签,由用户通过 openDialog 请求提供。
我正在尝试为此目录中的文件创建另一个安全范围书签:
NSURL *musicFolder = /* Secured URL Resolved from a NSData, bookmark not stale */;
if (![musicFolder startAccessingSecurityScopedResource]) {
NSLog(@"Error accessing bookmark.");
}
NSString *file = @"myfile.txt"; /* This file exists inside the directory */
NSURL *pathURL = [musicFolder URLByAppendingPathComponent:file];
NSError *systemError;
NSData *bookmarkData = [pathURL bookmarkDataWithOptions:NSURLBookmarkCreationWithSecurityScope
includingResourceValuesForKeys:nil
relativeToURL:nil
error:&systemError];
[musicFolder stopAccessingSecurityScopedResource];
if (!bookmarkData) {
NSLog(@"%@", systemError);
}
两者都bookmarkData
以systemError
nil 结尾,这不是很有用...
这是否受支持,或者您只能从系统中获得有效的安全范围书签?