たとえば、アプリをシャットダウンするときに同期する場合:
- (void)applicationWillResignActive:(UIApplication *)application
{
[[NSUserDefaults standardUserDefaults] synchronize];
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
最初にダミー ファイルへの書き込みを試み、その後アトミック リネームを実行します。書き込みに時間がかかりすぎると、ダミー ファイルになってしまいます。
私の場合、14MB の plist を持つユーザーが何人かいて、多くのダミー ファイル (ほぼ 2G を消費) を持つことになりました。
私の問題と修正は、ユーザーデフォルトに書き込んだ画像を圧縮することでした。