Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

[NSCFString timeIntervalSinceReferenceDate]: unrecognized selector sent to instance

I would like to compare difference between two dates, but with the code below I got the error "[NSCFString timeIntervalSinceReferenceDate]: unrecognized selector sent to instance." What's wrong with the code?

NSDate *dateAdded=[eventDictionary objectForKey:@"dateAdded"];
NSDate *validUntilDate=[eventDictionary objectForKey:@"validUntilDate"];
NSDateComponents *sometimeAgo = [[NSCalendar currentCalendar] components:(NSSecondCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit) fromDate:dateAdded  toDate:validUntilDate  options:0]; 
like image 454
Nimit Pattanasri Avatar asked Jun 25 '11 17:06

Nimit Pattanasri


1 Answers

It looks like dateAdded and/or validUntilDate are actually strings and not dates. Maybe they are strings representing dates, but strings after all.

like image 62
albertamg Avatar answered Oct 06 '22 09:10

albertamg