Challenge Error Message


I’m getting this error message;
:exclamation: ‘NSCalendar’ may not respond to ‘timeIntervalSinceDate’

for the code: NSCalendar *g = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSDate *dateOfBirth = [g dateFromComponents:comps]; double d = [g timeIntervalSinceDate:dateOfBirth];

Thank you


If you look at the documentation for NSCalendar ( … endar.html), you’ll see that it doesn’t define timeIntervalSinceDate. The compiler is hedging its bets when it says that NSCalendar “may not” respond.

NSDate, however, does, so you need to create another date object representing the current time and use that instead.