ipad - Compare two NSDates in iPhone -


I am new to the iPhone developer,

I want to compare two dates, the first date The database will come from, newDate and the other is today's date,

If today is more then newDate then I want to display the warning.

Here is my code snippet,

  NSString * newDate = [formatter stringFromDate: st]; NSDT * today = [[NSDT allok] Init]; If (compare to today: newdata) == NSordard denending) {NSLog (@ "@ today is a new date compared to date"); } And if ([Compare today: newdeat] == ​​NSordadding) {NSLog (@ "Today is better than today's date"); } Other {nslog (@ "date is same"); }   

but it crashes, and when I compile it, I also see a warning here [compare today: new date]

Any help would be appreciated.

The problem is, that you are comparing stars and dates if you < Code> newDate , you will see that it has no NSString and NSDate . If you use compare: on the law NSDate , both objects should be NSDate s. Looking at your code, it looks like st is related to NSDate related to newDate (though your naming sounds a bit strange), try Today with newDate instead of

Comments