【问题标题】:iOS: Tabs and document directoryiOS:选项卡和文档目录
【发布时间】:2012-05-15 20:36:27
【问题描述】:

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

它在一个标签而不是另一个标签上工作的任何原因?

【问题讨论】:

  • 您是否在您的 FourthViewController 中实现了:applicationDocumentsDirectory ?

标签: ios tabs directory document


【解决方案1】:

我猜你正在使用这篇文章中的代码:

How to get URL for application's document directory iPhone

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

我个人会将这样的方法放在帮助类中,并将其标记为静态方法,以便我可以调用它,例如[MyHandyUtils applicationDocumentsDirectory].

【讨论】:

  • 不,我没有使用您链接到的代码。我将使用单例来获取和存储目录路径,但我很好奇为什么会收到此错误消息。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-05-23
  • 2015-04-02
  • 2019-08-11
  • 1970-01-01
  • 2015-10-20
  • 2012-08-04
相关资源
最近更新 更多