Fetching Dates Which Comes Between StartDate and EndDate

旧街凉风 提交于 2019-12-30 11:24:15

问题


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 solving this... thanks in advance


回答1:


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



回答2:


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



来源:https://stackoverflow.com/questions/10216991/fetching-dates-which-comes-between-startdate-and-enddate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!