Hey i am trying to compare the date on which the user opens the app to the date it is currently. (basically, how long they’ve had the app in days)
Here is the code:
- (NSInteger) daysAfterDate: (NSDate *) aDate
{
NSTimeInterval ti = [self timeIntervalSinceDate:aDate]; //#1
return (NSInteger) (ti / D_DAY); //#2
} //#3
-(void)load {
NSDate *birthdate = [prefs objectForKey:@"Birthdate"];
rock_Age = daysAfterDate(birthdate);
}
errors:
1.) it tells me incompatible types in initialization
2.) D_DAY Undecared
warning:
3.) control reaches end of non void function
If i did this completely wrong, (because for the life of me i cannot understand the NSDate class :/) I would gladly take an alternative to doing this 🙂
all help is appreciated,
Thank you
-Jackson Smith
The load method is correct, the following should work for
-[daysAfterDate:].1) is because self is probably no NSDate. Use
[NSDate date]to get the current time/date.2) is because you have to define
D_DAY3) only happens because of 2).
I hope this helps.
The following article might also be informative: (Ars Technica)