- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
在我的 finder 同步扩展中解析安全范围书签时出现以下错误。
Error Domain=NSCocoaErrorDomain Code=259 "The File couldn't be opened because it isn't in the correct format."
还有可能是 related logging :
Failed to read values in CFPrefsPlistSource<0x6080000ee380> (Domain: MyAppGroupName, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null)): Using kCFPreferencesAnyUser with a container is only allowed for System Containers, detaching from cfprefsd
我正在使用以下代码在容器应用程序中创建安全范围书签:
NSUserDefaults *sharedDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"com.mycomp.xyz"];
NSURL * theSelectedFolder = ....selected folder from NSOpenPanel....
NSData *bookmarkData = [theSelectedFolder bookmarkDataWithOptions:NSURLBookmarkCreationWithSecurityScope includingResourceValuesForKeys:nil relativeToURL:nil error:NULL];
[sharedDefaults setObject:bookmarkData forKey:@"BookmarkData"];
[sharedDefaults synchronize];
在 Finder 同步扩展中,我使用以下代码:
NSUserDefaults *sharedDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"com.mycomp.xyz"];
NSData *bookmarkData = [sharedDefaults objectForKey:@"BookmarkData"];
BOOL bookmarkDataIsStale;
NSError *err;
NSURL *userSelectedUrl = [NSURL URLByResolvingBookmarkData:bookmarkData options:NSURLBookmarkResolutionWithSecurityScope relativeToURL:nil bookmarkDataIsStale:&bookmarkDataIsStale error:&err];
我还添加了这个授权 key :Finder 同步扩展和容器应用程序中的 com.apple.security.files.bookmarks.app-scope
。
我是 cocoa 编程的新手,无法找到问题所在。
我做错了什么?有人可以帮我吗?
最佳答案
要保存只读书签数据,请使用位掩码[.withSecurityScope, .securityScopeAllowOnlyReadAccess]
; 不仅仅是.securityScopeAllowOnlyReadAccess
。
.securityScopeAllowOnlyReadAccess
When combined with the
.withSecurityScope
option, specifies that you want to create a security-scoped bookmark that, when resolved, provides a security-scoped URL allowing read-only access to a file-system resource; for use in an app that adopts App Sandbox.
url.bookmarkData(options: [.withSecurityScope, .securityScopeAllowOnlyReadAccess], includingResourceValuesForKeys: nil, relativeTo: nil)
仅使用 .securityScopeAllowOnlyReadAccess
在从主应用程序或扩展程序解析时给我问题中提到的错误:
Error Domain=NSCocoaErrorDomain Code=259 "The file couldn’t be opened because it isn’t in the correct format."
关于objective-c - 使用 App Group UserDefaults 在 Finder 同步扩展中使用安全范围书签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37897118/
您知道,有时当您关闭 Finder 窗口或文档时,它会缩小到 Finder 中的显示位置。我希望我的应用程序也能够做到这一点。有这方面的API吗?我找不到。 最佳答案 执行摘要:如果您想要这种行为,请
我是 MAC 开发的新手,使用 finder 同步扩展并成功地为文件和文件夹设置了徽章图标,但我的问题是,当我完成将任何文件或文件夹同步到服务器时,徽章图标不会将表单同步更改为完成状态。请给我任何建议
在我的应用程序中,我喜欢让 OSX Finder 复制文件或文件夹。 (注意:我有充分的理由使用 Finder 而不是使用 shell cmds、NSWorkspace 或其他方式,因此无需在该方向上
我创建了一个简单的 Finder Sync (FinderSync) 扩展 (appex),默认情况下,应用程序沙盒处于打开状态(在 .entitlements com.apple.security.
我已经阅读了有关此主题的关于Stackoverflow的另一篇文章,但这几乎是所有基于Windows的工具。我当前正在运行Mac,在提到的所有工具中,http://xpath.alephzarro.c
我正在使用GORM查找器,但遇到运行时错误,我认为那是因为我的语法不正确。这是我遇到问题的代码行: def accountsOwnedByUser = AccountRecord.findAllWhe
我在 iPhone 上运行 iOS 应用程序,并记录了文档目录和 .plist 文件路径。刚刚更改了数据模型,所以我需要进入我的 .plist 并删除原始文件。 转到 Finder,按 Command
我目前正在开发一个实用程序,需要在对用户的默认设置进行一些更改后重新启动 Finder。 为了安全起见,我想在调用killall Finder(通过NSTask)之前检查Finder是否忙。如果 Fi
如何从特定文件夹中的 python 启动新的 Finder 窗口(或 Win 上的资源管理器)。我正在寻找的行为相当于 iTunes 或大多数其他程序想到它的轨道上下文菜单中的“在查找器中显示”链接。
进程文件: finder or finder.exe 进程名称: Microsoft Office Advanced Find Facility 进程类别:存在安全风险的进程 英文描述: f
我从 Swift 开始,我想创建一个应用程序来在 Finder 中加载选定的文件并执行一些操作,例如在 AppleScript 中。 糟糕的是我找不到任何关于如何做的信息。 在 AppleScript
我想从终端打开 Finder,并选择一个特定的文件。我知道通过使用 open .我可以在 Finder 中打开当前目录,但我也想在 Finder 窗口中选择一些文件。 我想要做的基本事情是运行一个脚本
我正在尝试使用 AppleScript 在 Finder 中打开一个文件夹。以下是我的代码。我想要文件夹 WorkSpace在 Finder 中打开,但它会打开父文件夹 /Volumes/MyMacD
我尝试使用 Application Scripting Bridge 让我的 Mac 进入休眠状态。代码如下所示: #import "Finder.h" FinderApplication *Fin
所以,我正在开发一个显示有关当前计算机的一些信息的应用程序,我希望它与 Finder 非常相似。当您在 Finder 中的计算机上获取信息时,会出现一个带有计算机大图标的预览部分。我希望能够在我的代码
我创建一个 cocoa 应用程序项目,并添加目标“Finder同步扩展”。然后“finderSync.appex”将被放入“.../Contens/Plugins/”文件夹中。但是当我启动应用程序时,
我希望能够为一些具有自定义扩展名的图像文件(例如,实际上是 TIFF 的 .canon 文件)生成自己的缩略图,以便 Finder 可以使用它们。 我不想更改文件内容(我对嵌入的 tiff 缩略图也不
我想要获取文件的“Kind”查找器。例如,对于文件“foo.css”,我想要字符串“CSS样式表”。 到目前为止,我正在做这样的事情: NSURL *fileURL = [[NSURL alloc]
通常为了分发一个简单的 cocoa 应用程序,我们对其发布文件夹进行 dmg 处理。当我们双击它时,它会安装其图像并显示一个不可编辑的窗口,其中包含 .app 和/或其他文件(例如 dSYM)。现在出
如何制作一个与 Finder 窗口具有相同基本结构的窗口(左侧的菜单/源列表,带有可以组织的图标,右侧的较大 View 中的内容)? 最佳答案 要复制 Finder 的内容 View ,请使用: 图标
我是一名优秀的程序员,十分优秀!