开发者

Filter NSSCrollView using date

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]];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜