Subject: Re: Core Data entity fetching by date
Subject: Re: Core Data entity fetching by date
- Subject: Subject: Re: Core Data entity fetching by date
- From: Steve Steinitz <email@hidden>
- Date: Mon, 10 Nov 2008 11:45:48 +1100
Hi,
Quincy gave such a masterful and complete answer that I felt
compelled to also make a small contribution. If you decide to
go the in-memory route, this simple routine may save you a few
minutes of head scratching:
- (BOOL)
selectedRangeContainsDate: (NSDate *) date
{
NSComparisonResult fromDateResult = [date compare: [self fromDate]];
NSComparisonResult toDateResult = [date compare: [self toDate]];
BOOL isAfterFromDate = (fromDateResult == NSOrderedSame) ||
(fromDateResult == NSOrderedDescending);
BOOL isBeforeToDate = (toDateResult == NSOrderedSame) ||
(toDateResult ==
NSOrderedAscending );
return isAfterFromDate && isBeforeToDate;
}
I used it in an NSArrayController subclass with a couple of date
pickers but you could adapt it for programmatically-generated
date ranges.
Cheers,
Steve
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden