EKEventStore Programming Xcode iOS Asynchronous Search

155 views Asked by At

The Documentation states:

  • (void)enumerateEventsMatchingPredicate:(NSPredicate *)predicate usingBlock:(EKEventSearchCallback)block

This method is synchronous. For asynchronous behavior, run the method on another thread with dispatch_async or NSOperation.

How do you make this asynchronous, the sentence doesn't really demonstrate it. Could anyone clarify?

Thanks

D :-)

1

There are 1 answers

0
Daij-Djan On BEST ANSWER

either dispatch it all:

#include <stdio.h>

int main(int argc, char *argv[]) {
    ...
    dispatch_async(dispatch_get_global_queue(0,0), ^{
        [store enumerateEventsMatchingPredicate:p usingBlock:^(..) {
            //DO IT
        }];
    });
    ...
}

or the callbacks

#include <stdio.h>

int main(int argc, char *argv[]) {
    ...
    [store enumerateEventsMatchingPredicate:p usingBlock:^(..) {
        dispatch_async(dispatch_get_global_queue(0,0), ^{
        //DO IT
        });
    }];

    ...
}