iOS:选项卡和文档目录

iOS:选项卡和文档目录,ios,tabs,directory,document,Ios,Tabs,Directory,Document,我正在写一个有四个标签的应用程序。在第二个选项卡中,我将数据存储在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

我正在写一个有四个标签的应用程序。在第二个选项卡中,我将数据存储在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方法中有它


它在一个选项卡上工作而不是在另一个选项卡上工作的原因是什么?

我猜您使用的是本文中的代码:

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


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

您是否在第四个ViewController中实现了:applicationDocumentsDirectory?不,我没有使用您链接的代码。我将使用单例来获取和存储目录路径,但我很好奇为什么会收到这个错误消息。