finding NSDate's in an NSArray that have a time of day after a given time (e.g. 8pm)?

强颜欢笑 提交于 2019-12-06 13:29:55

There is no need to break in NSDateComponents.

NSTimeInterval interval = [date1 timeIntervalSinceDate:date2];
if (interval > 0) {
    // date2 is earlier
} else {
    // date1 is earlier
}

Now you can represent your target time(8 P.M., for example) with date2 and compare all dates of array with that.

Haven't tried this myself, but I guess

- (NSArray *)filteredArrayUsingPredicate:(NSPredicate *)predicate

is what you're looking for.

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