0
votes

I have data stored where one of the entity's attributes is startTime which is stores as an NSNumber (NSTimeInterval) and another attribute with the item's duration.

How would I go about fetching the single item which is valid for "now" - i.e. teh item who's start time + duration includes the current time ([NSDate date])?

2

2 Answers

1
votes

Have a look at this SO question: NSPredicate syntax for DATEADD?

0
votes

You need to use an NSDateFormatter to grab the current time/date and then use NSDateComponents to break this into hours/mins/seconds (as required).

Then increment your startTime and duration onto it.

Then use the components to create a new NSDate which will be your result.