OSX 10.6でXCode 4.2を使用して、iOS 5.0でUIManagedDocumentを使用し、シミュレーターでアプリを実行しています。問題のコードは次のようになります。
if (![[NSFileManager defaultManager] fileExistsAtPath:[self.photoDatabase.fileURL path]]) {
// does not exist on disk, so create it
[self.photoDatabase saveToURL:self.photoDatabase.fileURL forSaveOperation:UIDocumentSaveForCreating completionHandler:^(BOOL success) {
[self setupFetchedResultsController];
[self fetchFlickrDataIntoDocument:self.photoDatabase];
}];
} else if (self.photoDatabase.documentState == UIDocumentStateClosed) {
// exists on disk, but we need to open it
// *** the following line generates the message ***
[self.photoDatabase openWithCompletionHandler:^(BOOL success) {
//[self setupFetchedResultsController];
}];
} else if (self.photoDatabase.documentState == UIDocumentStateNormal) {
// already open and ready to use
[self setupFetchedResultsController];
}
マークされた行を実行すると、ログに次のメッセージが作成されます。
2012-01-10 22:33:17.109 Photomania[5149:4803] NSFileCoordinator: A surprising server error was signaled. Details: Connection invalid
メッセージが送信された後、UIManagedDocument が機能する場合と機能しない場合があります。これを決定する状況はまだわかりません。
実際にはスタンフォード大学の CS193p コースのコード例の 1 つであるため、このコードが正しいと確信しています。サンプル全体は、 http: //www.stanford.edu/class/cs193p/cgi-bin/drupal/ の下の Web サイトでダウンロードできます 。 コードへの直接リンク: http://www.stanford.edu/class/cs193p/ cgi-bin/drupal/system/files/sample_code/Photomania_0.zip
さらに、コードは「驚くべき」メッセージを生成せずにデバイス自体で正常に実行され、その後のすべてのコードが正常に実行されます。
Google でも Apple Developer ページでも何も見つかりませんでした。シミュレータまたは XCode を再起動するか、両方を再インストールしても、動作は変わりません。
何か案は?