我在开发我的 iphone 应用程序时遇到了重大问题。
这是完整的错误:
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 实体( Locations 和 TimeSpentStudying)。但我不认为这些是问题。[TimeSpentStudying coordinate]
很奇怪,因为我没有在核心数据类coordinate
上发送的属性TimeSpentStudying
我设置了 mapView,当用户点击 mkannotationview 上的详细信息披露按钮时,会弹出一个新视图 (LibraryTrackTimeViewController),但几乎无法使用。我尝试在 viewDidLoad 中调用 NSLog 并没有显示任何内容。
地图视图控制器.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 中的 prepareForSegue 方法有关的错误
-(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;
}
}}
我为粗略的语法道歉,我刚刚习惯了,如果您需要更多代码,请告诉我,谢谢大家。