I am a newbie with iphone programming. I need some help with this code.
I found what I needed here- http://stackoverflow.com/questions/1072848/how-to-check-if-an-nsdate-occurs-between-two-other-nsdates/
But I have no idea how to use this block of code.
+ (BOOL)date:(NSDate*)date isBetweenDate:(NSDate*)beginDate andDate:(NSDate*)endDate
{
if ([date compare:beginDate] == NSOrderedAscending)
return NO;
if ([date compare:endDate] == NSOrderedDescending)
return NO;
return YES;
}
I need help on how to use this function.
I created NSDATE+Helper.h and NSDATE+Helper.m
My NSDATE+Helper.h
#import <Foundation/Foundation.h>
@interface NSDATEHelper : NSDate {
}
@end
NSDATE+Helper.m
#import "NSDATE+Helper.h"
@implementation NSDATE (Helper)
+ (BOOL)date:(NSDate*)date isBetweenDate:(NSDate*)beginDate andDate:(NSDate*)endDate
{
if ([date compare:beginDate] == NSOrderedAscending)
return NO;
if ([date compare:endDate] == NSOrderedDescending)
return NO;
return YES;
}
This is not working. I am getting some errors. Can you please help with this.