これは意味がないことはわかっていますが、Core Data を使用して CGRectOffset を呼び出して構築している iPhone アプリで、非常に奇妙なエラーが発生します。私のアプリ デリゲートの didFinishLaunchingWithOptions メソッドは次のようになります。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Setup the Managed Object Context
NSManagedObjectContext *context = [self managedObjectContext];
if (!context) {
// Do something - Like exit
}
//Load up the database form a pList
NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"tJournals" ofType:@"plist"];
NSMutableArray *plistJournals = [NSMutableArray arrayWithContentsOfFile:plistPath];
//Create a bunch of journals
for (NSDictionary *journal in plistJournals) {
[TJournal journalWithDictionary:journal inManagedObjectContext:context];
}
NSError *error = nil;
[context save:&error];
// ------ Create the View Controller ------
// The Scrolling List
JournalListVC *jvc = [[JournalListVC alloc] init];
// Adjust for the Status Bar's height
CGRect viewFrame = CGRectOffset(jvc.view.frame, 0.0, 20.0);
jvc.view.frame = viewFrame;
jvc.managedObjectContext = context;
// Add the View Controller to the screen
[self.window addSubview:jvc.view];
[self.window makeKeyAndVisible];
return YES;
}
現在、 CGRect ビューフレーム行をそのままにしておくと、次のエラーでアプリがクラッシュします。
「キャッチされない例外 'NSInternalInconsistencyException' が原因でアプリを終了しています。理由: '+entityForName: エンティティ名 'TJournal'' の NSManagedObjectModel が見つかりませんでした」
CGRect 行をコメントアウトすると、問題なく動作します。for ループ内の呼び出しは正常に実行されます (TJournal という名前の Core Data DB エンティティにデータを書き込み、想定どおりに動作します)。明らかに、CGRectOffset の Core Data への依存はないため、このエラーはスプリアス。しかし、私は一生、それを理解することはできません。
すべてのターゲットのクリーニング、シミュレーターのデータベースの消去などを試みましたが、何も機能していないようです。
何か案は?ありがとう!