Iphone 尝试将elapsedTime保存到coreData

Iphone 尝试将elapsedTime保存到coreData,iphone,ios,core-data,nsmanagedobjectcontext,Iphone,Ios,Core Data,Nsmanagedobjectcontext,我的应用程序的一个核心功能是允许用户跟踪在某个位置花费的时间。然而,我(显然)遇到了一个严重的错误。我有两个核心数据实体:Location用于保存用户的位置,以及timespunt用于保存在该位置经过的时间(多对多关系)。我附上一个屏幕截图以使其更清晰: 这是我的学习课: #import <Foundation/Foundation.h> #import <CoreData/CoreData.h> @class Location; @interface TimeSp

我的应用程序的一个核心功能是允许用户跟踪在某个位置花费的时间。然而,我(显然)遇到了一个严重的错误。我有两个核心数据实体:
Location
用于保存用户的位置,以及
timespunt
用于保存在该位置经过的时间(多对多关系)。我附上一个屏幕截图以使其更清晰:

这是我的学习课:

#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>

@class Location;

@interface TimeSpentStudying : NSManagedObject

@property (nonatomic, retain) NSString * libraryNameText;
@property (nonatomic, retain) NSDate * date;
@property (nonatomic, retain) NSNumber * timeSpent;
@property (nonatomic, retain) Location *info;

@end
当我启动计时器时-收到此错误:

<TimeSpentStudying: 0x1e441130> (entity: TimeSpentStudying; id: 0x1d5a4260 <x-coredata:///TimeSpentStudying/t3B884C6F-8210-4B9E-A716-23DEC24291482> ; data: {
    date = nil;
    info = nil;
    libraryNameText = nil;
    timeSpent = 0;
})
2013-01-29 17:46:25.885 BooksonBooksonBooks[18856:907] -[TimeSpentStudying coordinate]: unrecognized selector sent to instance 0x1e441130
2013-01-29 17:46:25.892 BooksonBooksonBooks[18856:907] 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 0x1e441130 with userInfo (null)
2013-01-29 17:46:25.899 BooksonBooksonBooks[18856:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TimeSpentStudying coordinate]: unrecognized selector sent to instance 0x1e441130'
我不太理解这个错误。我是否必须在我的
LibraryTrackTimeViewController
中创建全新的managedObject上下文,专门用于
TimePentStudio
?我希望每个
位置
对象都保存多个
时间间隔(日期、时间间隔等)。我希望我说得够清楚了。如果您需要查看更多的
LibraryTrackTimeViewController
-请告诉我,谢谢

错误在这里:

BooksonBooks[18856:907]-[TimesPents]:发送到实例0x1e441130的无法识别的选择器

您在TimePentStuding类的对象上调用“坐标”,该类对象未实现该方法,这导致应用程序崩溃


由于我在您发布的任何代码中都没有看到坐标,并且您说您的另一个实体类型是location,它可能包含坐标,所以您可能正在传递一个位置,您想传递一个TimePent。您使用的是ARC吗?

这通常是NSManagedObjectContextObjectsIDChangeNotification的观察者中的一个错误。
那么,您有吗?如果是的话,你能添加它的代码吗?
<TimeSpentStudying: 0x1e441130> (entity: TimeSpentStudying; id: 0x1d5a4260 <x-coredata:///TimeSpentStudying/t3B884C6F-8210-4B9E-A716-23DEC24291482> ; data: {
    date = nil;
    info = nil;
    libraryNameText = nil;
    timeSpent = 0;
})
2013-01-29 17:46:25.885 BooksonBooksonBooks[18856:907] -[TimeSpentStudying coordinate]: unrecognized selector sent to instance 0x1e441130
2013-01-29 17:46:25.892 BooksonBooksonBooks[18856:907] 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 0x1e441130 with userInfo (null)
2013-01-29 17:46:25.899 BooksonBooksonBooks[18856:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[TimeSpentStudying coordinate]: unrecognized selector sent to instance 0x1e441130'
-(IBAction)startTimer:(id)sender
{
  startTime = [[NSDate alloc] init];

  elapsedTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateTimer) userInfo:nil repeats:YES];

  TimeSpentStudying *timeSpentStudying = [NSEntityDescription insertNewObjectForEntityForName:@"TimeSpentStudying" inManagedObjectContext:self.managedObjectContext];

  timeSpentStudying.timeSpent = [NSNumber numberWithDouble:totalTimeSpentStudying];