CoreData误解对象类 [英] CoreData misinterpreting object class

查看:93
本文介绍了CoreData误解对象类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

保存我的核心数据上下文时,出现以下错误。
我真的不知道从哪里开始看,如果你有一个领导...
谢谢。



PS:在.h文件中声明的所有类型都与我的数据模型中相同。



编辑:我在NSDate类别中覆盖了intValue。现在我看到timeIntervalSinceReferenceDate在NSNumber上被调用。我试图把一个断点,但它没有信息(只保存:是在我的代码之前)。我还发现了一种方法来知道是谁是那些着名的对象:NSDate是一个对象(称为lastCompute)在与NSNumber(称为睡眠)相同的类。它们的类型匹配在.h中声明的类型和数据模型。但它不给我一个提示为什么CoreData在NSDate上调用intValue。任何铅?感谢

   -  [__ NSDate intValue]:无法识别的选择器发送到实例0x6a3cba0 
***由于未捕获异常终止应用程序'NSInvalidArgumentException',reason:' - [__ NSDate intValue]:无法识别的选择器发送到实例0x6a3cba0'
***首次调用堆栈:

0 CoreFoundation 0x01ca35a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x01df7313 objc_exception_throw + 44
2 CoreFoundation 0x01ca50bb - [NSObject(NSObject)doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x01c14966 ___ forwarding___ + 966
4 CoreFoundation 0x01c14522 _CF_forwarding_prep_0 + 50
5 CoreData 0x00955b50 - [NSSQLiteConnection execute] + 2320
6 CoreData 0x009a7ebd - [NSSQLiteConnection updateRow:] + 365
CoreData 0x009a6e64 - [NSSQLConnection performAdapterOperations:] + 180
8 CoreData 0x009a6b0e - [NSSQLCore _performChangesWithAdapterOps:] + 494
9 CoreData 0x009a55ea - [NSSQLCore performChanges] + 410
10 CoreData 0x0099f038 - [NSSQLCore saveChanges:] + 216
11 CoreData 0x0095d199 - [NSSQLCore executeRequest: withContext:error:] + 409
12 CoreData 0x00a0d70b - [NSPersistentStoreCoordinator executeRequest:withContext:error:] + 3691
13 CoreData 0x00995948 - [NSManagedObjectContext save:] + 712


解决方案

我想我解决了这个问题。

我试图删除NSDate属性。发生了一个新错误(解释此处)。所以我检查了所有我的[NSNumber numberWithSomething:],我发现我是把数字创建的数字在数据模型中声明为float的属性。

我修复了所有这些错误,重新添加NSDate和现在我的应用程序不会崩溃了。我希望这是解决方案,即使它与在NSDate上调用intValue无关。


When saving my core data context I have the following error. I have really no idea where to start looking at, if you have even a lead... Thank you.

PS: I checked that all types declared in .h files are the same as in my Data Model.

EDIT : I overwrote intValue in a category of NSDate. Now I see that timeIntervalSinceReferenceDate is called on a NSNumber. I tried to put a breakpoint there but it gives no info (only save: is before my code). I also found out a way to know who is those famous objects : NSDate is an object (called lastCompute) in the same class as the NSNumber (called sleep). Their type match the types declarated in .h and data model. But it does not give me a hint on why CoreData calls intValue on an NSDate. Any lead ? Thanks

-[__NSDate intValue]: unrecognized selector sent to instance 0x6a3cba0
 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDate intValue]: unrecognized selector sent to instance 0x6a3cba0'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x01ca35a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x01df7313 objc_exception_throw + 44
    2   CoreFoundation                      0x01ca50bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
    3   CoreFoundation                      0x01c14966 ___forwarding___ + 966
    4   CoreFoundation                      0x01c14522 _CF_forwarding_prep_0 + 50
    5   CoreData                            0x00955b50 -[NSSQLiteConnection execute] + 2320
    6   CoreData                            0x009a7ebd -[NSSQLiteConnection updateRow:] + 365
    7   CoreData                            0x009a6e64 -[NSSQLConnection performAdapterOperations:] + 180
    8   CoreData                            0x009a6b0e -[NSSQLCore _performChangesWithAdapterOps:] + 494
    9   CoreData                            0x009a55ea -[NSSQLCore performChanges] + 410
    10  CoreData                            0x0099f038 -[NSSQLCore saveChanges:] + 216
    11  CoreData                            0x0095d199 -[NSSQLCore executeRequest:withContext:error:] + 409
    12  CoreData                            0x00a0d70b -[NSPersistentStoreCoordinator executeRequest:withContext:error:] + 3691
    13  CoreData                            0x00995948 -[NSManagedObjectContext save:] + 712

解决方案

I think I solved the problem.
I tried to remove the NSDate attribute. A new error came up (explained here). So I checked all my [NSNumber numberWithSomething:] and I found out I was putting numbers created with int in attributes declared as float in data model.
I fixed all those mistakes, re-added the NSDate and now my app doesn't crash any more. I hope this was the solution even if it has nothing to do with intValue being called on an NSDate.

这篇关于CoreData误解对象类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆