I'm having problem filtering an NSScrollViews contents using it's date column.
I have an Entity that it's contains several attributes, such as Name , AccountNumber , DateOfPurchase , etc. This entity is b开发者_如何学运维ound to an NSArraycontroller.
Also, I have an NSScrollView that it's columns is bounded to this NSArrayController.
The problem is that I want to filter this NSScrollView records to show just the records that they are limited by interval of 2 date. ( like : after 10/02/2010 and before 05/05/2011 )
What should I do to do this ?
Problem solved using FilterPredicate :
NSDate *afterDate=[balanceDateAfter objectValue];
NSDate *beforeDate=[balanceDateBefore objectValue];
NSComparisonResult duration=[beforeDate timeIntervalSinceDate:afterDate];
duration=duration/3600;
duration=duration/24;
NSLog(@"After Date is : %@",afterDate);
NSLog(@"Before Date is : %@",beforeDate);
[checkInBalanceArray setFilterPredicate:[NSPredicate predicateWithFormat:@"(checkDate >= %@) AND (checkDate <= %@)", afterDate, beforeDate]];
[checkOutBalanceArray setFilterPredicate:[NSPredicate predicateWithFormat:@"(checkDate >= %@) AND (checkDate <= %@)", afterDate, beforeDate]];
精彩评论