0
votes

I am trying to store a date field from a PFObject into my date type attribute of a Core Data entity.

coreDataObject.createdAt  = [object createdAt];

This is the error XCode is returning : property = "updatedAt"; desired type = NSDate; given type = __NSCFString;

Before doing this I was storing the date as a string and parsing that [object createdAt] and everything was working fine, but now it doesn't recognize it as a NSDate.

I've tried casting in but nothing seems to work.

Any idea?


Note, it's this simple:

NSDate *teste = oneParseRow.createdAt;
NSLog(@"teste is %@", ttt);

Note that:

[oneParseRow objectForKey:@"createdAt"];

or anything similar, simply does not work, in any way. You just have to use .createdAt.

1
What is the class of 'object'? It seems that the method createdAt of object is returning a string.Juan Catalan
object is a PFObject, an object from Parse frameworkmanuvendev
Why does your error message mention updatedAt, but your code sample is using createdAt? Any chance the error is not in this code you posted?Héctor Ramos
EXACTLY @HectorRamos ,my bad, I was so focused on createdAt that I forgot I had another property called updatedAt due to the length of my code. Thanks!manuvendev

1 Answers

0
votes

Could you verify in the Parse documentation that the createdAt method returns an NSDate? It seems that it is returning a NSString.

Try this code:

id created = [object createdAt]
coreDataObject.createdAt  = created;

Put a breakpoint in the first line and within the debugger inspect the type of object that createdAt is returning. If it is not an NSString instead of NSDate you will have to convert it to a NSDate with a NSDateFormatter.