私のiPhoneアプリの開発に大きな問題があります。私は2つのcoreDataエンティティ(場所& TimeSpentStudying)を持っているのでCoreData:error:深刻なアプリケーションエラーです。コアデータの変更処理中に例外がキャッチされました
CoreData: error: Serious application error. Exception was caught during Core Data
change processing. This is usually a bug within an observer of
NSManagedObjectContextObjectsDidChangeNotification. -[TimeSpentStudying coordinate]:
unrecognized selector sent to instance 0x21db92d0 with userInfo (null)
これは奇妙です:
は、ここに完全なエラーです。しかし、私はそれらが問題ではないと思う。 [TimeSpentStudying coordinate]
は、私がTimeSpentStudying
コアデータクラスに
を送っcoordinate
性質を持っていないので、私はセットアップのMapViewを持っており、ユーザーはmkannotationviewの詳細開示ボタン、新しいビュー(LibraryTrackTimeViewController)ポップでタップしたとき、奇妙ですしかし、ほとんど使用できません。私はviewDidLoadでNSLogを呼び出してみましたが、何も表示されませんでした。
mapViewController.m
#pragma mark - NSNotification
- (void)contextDidChange:(NSNotification *)notification
{
if ([self isViewLoaded]) {
[self updateLocations];
}
。
- (void)updateLocations
{
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Location" inManagedObjectContext:self.managedObjectContext];
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setEntity:entity];
NSError *error;
NSArray * foundObjects = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];
if (foundObjects == nil) {
FATAL_CORE_DATA_ERROR(error);
return;
}
if (locations != nil) {
[self.mapView removeAnnotations:locations];
}
locations = foundObjects;
[self.mapView addAnnotations:locations];
}
-(void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self
name:NSManagedObjectContextObjectsDidChangeNotification
object:self.managedObjectContext];
}
は、私が思うにエラーがmapViewController.m
私はラフな構文について謝罪-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if (distance < 500) {
if ([segue.identifier isEqualToString:@"TrackLibraryTimes"]) {
UINavigationController *navigationController = segue.destinationViewController;
LibraryTrackTimeViewController *controller = (LibraryTrackTimeViewController *)navigationController.topViewController;
controller.managedObjectContext = self.managedObjectContext;
}
}}
にprepareForSegue方法で行う必要があることがあります、私は慣れていますあなたがコードをもっと必要としたら、私に教えてください、ありがとう。
こんにちはようこそ!また、大きな質問! – doge
エラーメッセージは、 'coordinate'メッセージが' TimeSpentStudying'のインスタンス、おそらくアドレス0x21db92d0のオブジェクトに送信されることを明確に示しています。したがって、ある時点では、 'TimeSpentStudying'オブジェクトを使って作業しています。ここでは、別のタイプ(' Locations'?)が必要です。 Objective-Cの動的メソッド解決のために、このような問題は実行時にのみ明らかにされることがよくあります。問題の特定に努めてください。すべてのObjective-C例外にブレークポイントを設定します。 –