我遇到了开发我的iphone应用程序的主要问题。CoreData:错误:严重的应用程序错误。核心数据更改处理期间发生异常
这里是完整的错误:
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)
这是奇怪,因为我有两个coreData实体(位置& TimeSpentStudying)。但我不认为这是问题。 [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
错误消息清楚地表明'坐标'消息被发送到'TimeSpentStudying'的一个实例,可能是地址为0x21db92d0的对象。所以在某些时候,你正在使用一个'TimeSpentStudying'对象来预期不同的类型('Locations'?)。由于Objective-C中的动态方法解析,这些问题通常只在运行时才会显示出来。您应该尝试找出问题,例如通过设置所有Objective-C异常的断点。 –