1

ローカルバンドルパスにデータを保存するアプリの新しい更新をリリースする準備をしています。このパスに保存されているデータが更新時に削除されないようにしたいと思います。これは起こり得ますか、そして私は何に注意すべきですか?

これは、データを格納するためのパスを取得するために使用しているコードです。

// Temporary method variables
NSError *error;

// Create a list of paths
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

// Get the path to the apps documents directory from the array
NSString *documentsDirectory = [paths objectAtIndex:0];

// Create a full path to the file
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"FFUserPrefs.plist"];

// Access the file manager
NSFileManager *fileManager = [NSFileManager defaultManager];

// Check if the file exists and if not, copy from the bundle path to the documents path
if (![fileManager fileExistsAtPath:path])
{
    // Get path to file from bundle directory
    NSString *pathBundle = [[NSBundle mainBundle] pathForResource:@"FFUserPrefs" ofType:@"plist"];

    // Copy pref file to app documents folder
    [fileManager copyItemAtPath:pathBundle toPath:path error:&error];
}

ユーザーがこのディレクトリに保存したデータが失われる可能性があるので、更新後もデータが残っていることを確認したいと思います。私が尋ねる唯一の理由は、リリースアプリケーションがインストールされている電話でxCodeを介して新しいビルドを実行した後、データが消去されて新しく開始されたためです。私は何が欠けていますか?アプリバンドルパスはXcodeとリリースの間で変更されますか?どんな情報でも大歓迎です!

4

1 に答える 1

1

ドキュメントディレクトリに保存されているファイルは、アプリの更新中に削除されません。FFUserPrefs.plistはドキュメントディレクトリに保存されるため、更新後も引き続き存在します。ただし、アプリバンドル()に保存されているファイルは[NSBundle mainBundle]、新しいバンドルに置き換えられます。

于 2012-12-31T02:53:36.090 に答える