gpt4 book ai didi

iOS:选项卡和文档目录

转载 作者:行者123 更新时间:2023-11-29 04:39:31 36 4
gpt4 key购买 nike

我正在编写一个带有四个选项卡的应用程序。在第二个选项卡中,我将数据存储在 plist 中,并使用此代码设置路径:

//get the path to the documents directory (where we will store our plist)
NSString* docDirectory = [self applicationDocumentsDirectory];

//append the path to the documents diretory with our plist name
NSString* destPath = [docDirectory stringByAppendingPathComponent:@"surveyResults.plist"];

它有自己的方法。工作正常。

在第四个选项卡中,我放置了相同的代码,但我在 [self applicationDocumentsDirectory] ​​上收到错误:

No visible @interface for 'FourthViewController' declares the selector 'applicationDocumentsDirectory'

我在 viewDidLoad 方法中有它。

它在一个选项卡上运行而不在另一个选项卡上运行有什么原因吗?

最佳答案

我假设您正在使用这篇文章中的代码:

How to get URL for application's document directory iPhone

您只需要确保第四个选项卡的 ViewController 也包含此代码片段,我希望您只是忘记将其放入。

就我个人而言,我会将这样的方法放在辅助类中,并将其标记为静态方法,以便我可以使用以下方式调用它: [MyHandyUtils applicationDocumentsDirectory]。

关于iOS:选项卡和文档目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10600704/

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