gpt4 book ai didi

swift - 从 ViewController 访问 NSDocument

转载 作者:可可西里 更新时间:2023-11-01 01:37:27 25 4
gpt4 key购买 nike

我有一个 NSDocument,它保存和读取一些数据。我想在我的 ViewController 中使用这些数据。我怎样才能访问它?我还没有找到任何有关在 swift 中执行此操作的信息,仅在 obj-c 中,但是当我将其翻译成 swift 时,它总是失败。
更准确地说:
我有一本字典(我的文档属性),它存储所有数据——我从这本字典中保存并读取它。我想从 ViewController 访问这个属性(字典)。

最佳答案

我找到了一个解决方案:

(self.view.window?.windowController?.document as! Document).arch.objectForKey("saved")

重要的是 - 在 vi​​ewWillAppear 中调用它!

关于swift - 从 ViewController 访问 NSDocument,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35162023/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com