Fetching Dates Which Comes Between StartDate and EndDate

前端 未结 2 1645
情歌与酒
情歌与酒 2021-01-15 15:08

I am having array of dates and i need to fetch only those dates which comes between two differnt dates (StartDate and EndDate)..

can any one help me out in so

相关标签:
2条回答
  • 2021-01-15 15:09

    Assuming you have startDate and endDate instances of type NSDate you can:

    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(SELF > %@) AND (SELF < %@)", startDate, endDate];
    NSArray *result = [arrayWithDates filteredArrayUsingPredicate:predicate];
    
    0 讨论(0)
  • 2021-01-15 15:34

    Check out filterWithPredicate, it allows you to create a filter rule to apply against all elements in the array.

    0 讨论(0)
提交回复
热议问题