In my core data model I have an entity with an attribute of type Date. The date is stored by core data as a timeInterval since x. x being a reference date that core data uses. The problem is that the dates where entered manually as actual date strings instead of time intervals (I know the data should not be directly manipulated). My question therefore is: Is there a way I can directly get the data as a string (as it is stored by core data)? ValueForKey keeps returning a default date which is "2001-01-01 00:33:20 +0000" because it is failing to convert the data stored into an NSDate object. I do not want to change the attribute type from Date to String for a particular reason. Thank you!
0
votes
are you sure you are storing the date correctly? did you check code just before you store it?
– prince
Could you post the code where you save these values to Core Data?
– Tom Harrington
The dates were not stored correctly. They were entered manually into the database that core data is using. Saving the dates through code saves correctly (as time intervals (proven by checking the database)). As a result of the data that was manually entered, I have to retrieve it as is, and work with strings to convert then to NSDate. At the moment core data tries to convert the stored strings to NSDates and fails because they were not stored properly. I just need a way to access the data as strings instead of coredata trying to convert to the respective class, in this case NSDate.
– pnizzle