Fetching Dates Which Comes Between StartDate and EndDate

前端 未结 2 1644
情歌与酒
情歌与酒 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];
    

提交回复
热议问题