xcode 3.2.5 で新しい coredata プロジェクトを開始した後、いくつかの問題が発生しました... (以前の xcode で) コア データを使用した以前のプロジェクトは正常に機能したため、何が違いなのかわかりません??
したがって、ビルドしてコアデータを呼び出すビューに移動すると、エラーが発生します>
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
奇妙なことは、私の *AppDelegate.m にあることです (Rog に感謝しますが、まだ機能していません!)
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
if (persistentStoreCoordinator_ != nil) {
return persistentStoreCoordinator_;
}
NSString *storePath = [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"staff.sqlite"];
NSURL *storeUrl = [NSURL fileURLWithPath:storePath]; //new position for the storeUrl!
// Put down default db if it doesn't already exist
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:storePath]) {
NSString *defaultStorePath = [[NSBundle mainBundle] pathForResource:@"staff" ofType:@"sqlite"];
if (defaultStorePath) {
[fileManager copyItemAtPath:defaultStorePath toPath:storePath error:NULL];
}
}
の中に
NSString *storePath = [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"staff.sqlite"];
警告が表示されます
NSURL may not respond to '-stringByAppendingPathComponent'
このstringByAppendingPathComponentをオプション+クリックして取得します(シンボルが見つかりません!!!!)
しかし、他のプロジェクトでは、同じようにオプション+クリックして定義を取得します!!
- この警告は私のエラーに関連していますか??
- それを修正する方法は?
編集、これを私のviewDidLoadに含めました
NSLog(@"path= %@", [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]) ;
これにより、コンソールに次のように表示されます。
path= /Users/mkss9/Library/Application Support/iPhone Simulator/4.2/Applications/2F364C20-2B87-4ABB-AA3E-FB6F7C15096F/Documents
ください!, 私は狂っている !!
ありがとう!