'-[__NSDate ManagedObjectContext]:发送到实例的无法识别的选择器

发布于 2025-01-04 05:29:26 字数 1678 浏览 1 评论 0原文

我在核心数据中有一些实体,它们都是具有 NSDate 属性的超类的子类,

当我保存它们时,所有其他实体都运行良好,

但其中一个在我保存时似乎很可能会崩溃,

我发现原因是关于从其超类继承的 NSDate 属性,

当我设置 NSDate 属性的日期值时,它崩溃并注销:

2012-02-10 00:24:34.474 EasyWallet[37772:707] -[__NSDate managedObjectContext]: unrecognized 
selector sent to instance 0xdc54c30
2012-02-10 00:24:34.483 EasyWallet[37772:707] *** Terminating app due to uncaught exception 
'NSInvalidArgumentException', reason: '-[__NSDate managedObjectContext]: unrecognized 
selector sent to instance 0xdc54c30'
*** First throw call stack:
(0x344268bf 0x346761e5 0x34429acb 0x34428945 0x34383680 0x32f8811b 0x32f8904b 0x32f8aeb5   
0x32f83161 0x32f7e8cf 0x3c507 0x34380435 0x377ea9eb 0x377ea9a7 0x377ea985 0x377ea6f5 
0x377eb02d 0x377e950f 0x377e8f01 0x377cf4ed 0x377ced2d 0x30c01df3 0x343fa553 0x343fa4f5 
0x343f9343 0x3437c4dd 0x3437c3a5 0x30c00fcd 0x377fd743 0x29b1 0x2970)
terminate called throwing an exception(gdb) 

这是我用于保存这些属性的代码

... // get keys
 self.rowKeys = [NSMutableArray arrayWithObjects:@"personName",@"amount",@"incomingAccount",
                    @"date",@"returnDate",@"isReturned",@"memo",nil];
... // saving
for (int i = 0; i < [self.rowKeys count]; i++) {
    NSLog(@"%d: %@",i,[rowValues valueForKey:key(i)]);
    [newMo setValue:[self.rowValues valueForKey:key(i)] forKey:key(i)];
}

,这里的 key(i) 是一个宏定义:

#define key(X) [rowKeys objectAtIndex:(X)]

并打印日期就这样出来了,一点也不意外。

2012-02-10 16:00:00 +0000

当涉及到保存“日期”属性时,它会崩溃,但它刚刚通过的次数较少。

我从 UIDatePicker 获得了该日期,并且检查了我的代码,我认为没有发现任何错误。

真的需要一些帮助!

多谢!

I have some entities in core data, and they are all sub classes of a super class which has a NSDate attribute,

and all others works well when I save them,

but one of them would seemingly probabilisticly crash when I save it,

and I found the reason is about its NSDate attribute inherited from its super Class,

when I set the date value for the NSDate attribute, it crashes and log out this:

2012-02-10 00:24:34.474 EasyWallet[37772:707] -[__NSDate managedObjectContext]: unrecognized 
selector sent to instance 0xdc54c30
2012-02-10 00:24:34.483 EasyWallet[37772:707] *** Terminating app due to uncaught exception 
'NSInvalidArgumentException', reason: '-[__NSDate managedObjectContext]: unrecognized 
selector sent to instance 0xdc54c30'
*** First throw call stack:
(0x344268bf 0x346761e5 0x34429acb 0x34428945 0x34383680 0x32f8811b 0x32f8904b 0x32f8aeb5   
0x32f83161 0x32f7e8cf 0x3c507 0x34380435 0x377ea9eb 0x377ea9a7 0x377ea985 0x377ea6f5 
0x377eb02d 0x377e950f 0x377e8f01 0x377cf4ed 0x377ced2d 0x30c01df3 0x343fa553 0x343fa4f5 
0x343f9343 0x3437c4dd 0x3437c3a5 0x30c00fcd 0x377fd743 0x29b1 0x2970)
terminate called throwing an exception(gdb) 

and here is my code for saving these attributes

... // get keys
 self.rowKeys = [NSMutableArray arrayWithObjects:@"personName",@"amount",@"incomingAccount",
                    @"date",@"returnDate",@"isReturned",@"memo",nil];
... // saving
for (int i = 0; i < [self.rowKeys count]; i++) {
    NSLog(@"%d: %@",i,[rowValues valueForKey:key(i)]);
    [newMo setValue:[self.rowValues valueForKey:key(i)] forKey:key(i)];
}

the key(i) here is a macro define:

#define key(X) [rowKeys objectAtIndex:(X)]

and the date was printed out like this, with no surprise.

2012-02-10 16:00:00 +0000

when it comes to save "date" attribute, it crashes, but fewer times it just passed.

I got that date from a UIDatePicker, and I've checked my codes finding nothing wrong I think.

Really need some help!

Thanks a lot!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

葬﹪忆之殇 2025-01-11 05:29:26

我已经修好了。

问题是我犯了一个愚蠢的错误,将一些 NSDate 方法发送到非 NSDate 对象,在一些非常秘密的地方。

只需注意您的代码,尤其是令人困惑的部分。

I've fixed it.

The problem is that I made a silly mistake of sending some NSDate method to a non-NSDate ojbect, in some very secret place.

Just pay attention to your codes, especially confusing parts.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文