0

私は4つのタブを持つアプリを書いています。2番目のタブでは、データを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"];

それはそれ自身の方法にあります。正常に動作します。

4番目のタブに同じコードを配置しましたが、[selfapplicationDocumentsDirectory]でエラーが発生します。

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

viewDidLoadメソッドにあります。

あるタブで機能し、別のタブでは機能しない理由はありますか?

4

1 に答える 1

1

この投稿のコードを使用していると思います。

アプリケーションのドキュメントディレクトリiPhoneのURLを取得する方法

4番目のタブのViewControllerにもこのコードスニペットが含まれていることを確認する必要があります。これを挿入するのを忘れていると思います。

個人的には、このようなメソッドをヘルパークラスに配置し、静的メソッドとしてマークして、[MyHandyUtilsapplicationDocumentsDirectory]などで呼び出すことができるようにします。

于 2012-05-15T12:36:27.013 に答える