• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Subject: Re: Core Data entity fetching by date
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: Inviting to comment on Cocoa categories
  • Next by Date: Re: NSArrayController, bindings and NSUserDefaults
  • Previous by thread: Re: Cocoa and NSLog
  • Next by thread: Help with this crashing method
  • Index(es):
    • Date
    • Thread