开发者

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

开发者 https://www.devze.com 2023-01-22 22:32 出处:网络
I need a function which receives [NSDate date] and a string @\"2010-11-12\" and returns the amount of days between those two dates.

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

精彩评论

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

关注公众号