0

I am have a function called ..

-(BOOL)isDateOkForHistory:(NSDate *)dtHist
{
    bool dateOkForHistory = false;

    for(NSInteger i=0;i<m_histCount;i++)
    {
           if(dtHist > [m_dtHistory objectAtIndex:i])
           {       
               //execute some condition.....
           }
     }
}

here m_dtHistory is a NSMutableArray.......So my doubt is whether the if statement which i am checking is right..?

Regards Ranjit

1 Answer 1

1

NSDate objects should be compared using compare: method.
Example:

if ([dtHist compare:[m_dtHistory objectAtIndex:i]] == NSOrderedDescending) {

}

Documentation: http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSDate_Class/Reference/Reference.html

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.