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.