I have a list of data that is a schedule. Each item has a time that it takes place in. I want to detect the current day and time and then display what items are available during that time. All I really know is how to get todays date and time and that I need to create a method to look in my data at what is currently “playing”. Any suggestions?
Share
By assuming that your schedule items are stored in an
NSArraycalledscheduleItemsand that these items have adateproperty, you could filter them with a predicate:The problem is that this will give you every item where its date is exactly now. You probably want to compare the date in a range:
Note: this is not tested.