views:

41

answers:

1

Hi all,

if I have two nsdatecomponent and I want a know if the TIME in the first object is bigger than the second.

example:

if (nsdatecomponentObject1 > nsdatecomponentObject2)
{
    //something
}

Because this way don't works, how I can do this?

Alex

+2  A: 

Use compare: on the NSDate of the NSDateComponent.

if([[nsdatecomponentObject1 date] compare:[nsdatecomponentObject2 date]] == NSOrderedAscending)
Jacob Relkin
Note for Mac developers: This method only exists in the iOS version of Foundation (so far, anyway — it will probably be in Lion).
Chuck
the result of my comparaison is always 0, why?
alex
I think your answer only compare the date, because my thow nsdateobjects haves the same date but not the same "seconde component", and the result is nsorderedsame.
alex