I am writing an app with four tabs. In the second tab I am storing data in a plist and use this code to set the path:
//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"];
It is in it’s own method. Works fine.
In the fourth tab I placed the same code, but I get an error on the [self applicationDocumentsDirectory]:
No visible @interface for 'FourthViewController' declares the selector 'applicationDocumentsDirectory'
I have it in the viewDidLoad method.
Any reason it works on one tab and not another?
I presume you are using the code from this post:
How to get URL for application's document directory iPhone
You just need to ensure that the ViewController for your fourth tab also includes this code snippet also, I expect you’ve just forgotten to put it in.
Personally I’d place such a method in a helper class, and mark it as a static method so I can call it with, e.g. [MyHandyUtils applicationDocumentsDirectory].