Swift 如何使用iPhone作为扫描仪在Mac应用程序中获取文档
我正在尝试添加对使用iPhone将文档扫描到我的应用程序中的支持。当我在文本视图中右键单击时,我会在菜单中看到iPhone,我可以选择照相机或文档。当我选择camera时,图像会自动插入textview。选择文档时,将调用validrequestor,并返回所有类型的self。应用程序在那里工作。当我在手机上选择save the scan时,应用程序会崩溃 2020-06-26 10:05:25.657246-0700见我的健康[3825:106456][General] 引发了未捕获的异常 2020-06-26 10:05:25.657292-0700参见我的健康[3825:106456][General] 目标seeMyHealth.notesWindow由-[NSTextView]返回 ValidRequestStorForSendType:returnType:]不响应选择器 从粘贴板读取选择: 2020-06-26 10:05:25.659379-0700参见我的健康[3825:106456][General]( 0 CoreFoundation 0x00007fff376dfbe7 __异常预处理+250 1 libobjc.A.dylib 0x00007fff709de5bf objc_异常_抛出+48 但我的应用程序中定义了readSelection的两个版本。这两个版本都提供了什么Swift 如何使用iPhone作为扫描仪在Mac应用程序中获取文档,swift,continuity,Swift,Continuity,我正在尝试添加对使用iPhone将文档扫描到我的应用程序中的支持。当我在文本视图中右键单击时,我会在菜单中看到iPhone,我可以选择照相机或文档。当我选择camera时,图像会自动插入textview。选择文档时,将调用validrequestor,并返回所有类型的self。应用程序在那里工作。当我在手机上选择save the scan时,应用程序会崩溃 2020-06-26 10:05:25.657246-0700见我的健康[3825:106456][General] 引发了未捕获的异常 2
override func validRequestor(forSendType sendType: NSPasteboard.PasteboardType?, returnType: NSPasteboard.PasteboardType?) -> Any?
{
return self
}
func readSelection(from pasteboard: NSPasteboard,type: NSPasteboard.PasteboardType) -> Bool
{
return true
}
func readSelection(from pasteboard: NSPasteboard) -> Bool
{
return true
}
我找到了
@objc func readSelectionFromPasteboard(_: NSPasteboard) -> Bool
{
return true
}
太棒了!也许没有多少应用程序支持这一点。