Challenge Error Message


#1

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


#2

If you look at the documentation for NSCalendar (developer.apple.com/library/mac … 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.