I'm trying to have an XPC service call a reply block multiple times. It has some work to do that can take some time. In this situation, it makes sense for me to pass back results to the caller in batches.
The block has two parameters a BOOL and a dictionary. The BOOL is YES if XPC is finished with all its work, and the dictionary contains all arrays (each array has NSStrings).
That's about it.
So the method looks something like this:
-(void)inspectArticle:(NSString*)articleString reply:(void (^)(BOOL finished,NSDictionary*dict))reply
{
//partial work up here.
if (objectCount >= MAX_BATCH_SIZE)
{
reply(NO,dictionary);
//unload reported objects..and do more work...
}
//finished
reply(YES,dictionary);
}
After the first call to the reply block, it just poops out. XPC continues, but firing the block does nothing (the calling app doesn't get the message).