Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Swift中保存PDF currentDestination_Swift_Pdfkit - Fatal编程技术网

如何在Swift中保存PDF currentDestination

如何在Swift中保存PDF currentDestination,swift,pdfkit,Swift,Pdfkit,我正在使用coreData成功保存PDF currentDestination (我正在将数据保存为“字符串”) 但是,如何通过以下方式“调用”已保存的currentDestination: func go(to destination: PDFDestination) 到目前为止,我的情况如下: let page = bookmark?.bookmarkPage // this is a 'String' pdfView.go(to: page!) // error on

我正在使用coreData成功保存PDF currentDestination

(我正在将数据保存为“字符串”)

但是,如何通过以下方式“调用”已保存的currentDestination:

func go(to destination: PDFDestination)
到目前为止,我的情况如下:

let page = bookmark?.bookmarkPage // this is a 'String'

        pdfView.go(to: page!) // error on "(to: page!)"
这是我得到的错误:

Cannot invoke 'go' with an argument list of type '(to: String)'

“调用”保存的PDF currentDestination的正确方法是什么?

不确定是否仍需要帮助,但如果需要,则需要将pdfView.go(to:)方法传递给PDFPage对象,而不是字符串。要获取对所需PDFPage对象的引用,请尝试:

if let page = self.pdfView.document?.page(at: number) {
   self.pdfView.go(to: page!)
}
上面的“number”参数是整数,因此请确保将保存的字符串转换为整数:

number = Int(savedStringVariable)

希望这有帮助

非常感谢您抽出时间回答我的问题。我试试这个。