Q:

Core data fetch request with predicate. Need right NSPredicate

I got entity with two NSDate properties. They are here: startTime, endTime and two restrictions, they are here too: NSDate *begin, NSDate *end
But the problem is endTime can be nil
I need to fetch all entities which:
(entity.startTime >= begin) AND (entity.endTyme == nil)

if (endType == nil)
and 
(entity.startTime >= begin) AND (entity.endTyme <= end)

if (endTyme != nil)
How to make union from those two fetch predicates? Or maybe use filter?

A:

(Remark: You have edited your question heavily several times. I would be better to append
new information about your problem, otherwise comments and answers are difficult to 
understand for future readers.)
To fetch all objects where the start time is >= a given time, and the end time is nil or
<= a given time, you can use the predicate
[NSPredicate predicateWithFormat:@"(startTime >= %@) AND (endTime == nil OR endTime <= %@)",
       startTime, endTime]

