开发者

Getting number of days between [NSDate date] and string @"2010-11-12"

I need a function which receives [NSDate date] and a string @"2010-11-12" and returns the amount of days between those two dates.

More explanation: I need to store a date from a server in the format @"2010-11-12" in my NSUserdefaults. The meaning of this date is the expireDate of a feature in an iPhone App. Every time I pres开发者_运维问答s on a button for this feature I need to check if the difference in days between the current time->[NSDate date] and @"2010-11-12" is greater than 0. That means that the feature is disabled.

It's making me crazy, maybe it's dead simple.


Use an NSDateFormatter to convert the string to an NSDate - then compare the date objects.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜