したがって、メインスレッドで更新を行う必要があることはわかっています。私は、ドキュメントディレクトリを実行するデータベースを作成するために Apple のコードを使用しています。
// Creates a writable copy of the bundled default database in the application Documents directory.
- (void)createEditableCopyOfDatabaseIfNeeded {
// First, test for existence.
BOOL success;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"bookdb.sql"];
success = [fileManager fileExistsAtPath:writableDBPath];
if (success)
return;
// The writable database does not exist, so copy the default to the appropriate location.
NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"bookdb.sql"];
success = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&error];
if (!success) {
NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]);
}
}
そうです
[activityIndicator startAnimating];
[self createEditableCopyOfDatabaseIfNeeded];
アクティビティ インジケータが表示されません。コメント アウトする[self createEditableCopyOfDatabaseIfNeeded];
と、アクティビティ インジケーターが表示されます。これをデバッグして、何が起こっているのか、回転インジケーターが表示されない理由を確認する方法はありますか? ありがとう。