Search code examples
iosobjective-cnspredicateeventkit

Search ios reminders without date


I'm familiar with using the eventstore search predicates like predicateForIncompleteRemindersWithDueDateStarting:Ending:Calendars:

but I'm trying to figure out how I can search for any incomplete reminders that don't have any due date set. I've tried NSCompoundPredicate but eventstore won't fetch a predicate that's not created with its own predicate creation methods. Any ideas?

Edit: As per the documentation, passing nil for both start and end dates results in all reminders, not solely reminders without dueDates.


Solution

  • EDIT

    You can try to filter all incomplete reminders to get only without due date:

    [store fetchRemindersMatchingPredicate:predicate
                                completion:^(NSArray *reminders)
         {
             NSArray *myReminders = [reminders filteredArrayUsingPredicate:
                                     [NSPredicate predicateWithFormat:@"dueDateComponents = nil"]];
             NSLog(@"%@", myReminders);
         }];
    

    Documentation for predicateForIncompleteRemindersWithDueDateStarting:ending:calendars::

    Discussion
    Pass nil for startDate to find all reminders due before endDate. Similarly, pass nil for both startDate and endDate to get all incomplete reminders in the specified calendars.