This is a replacement class for CPDistributedMessagingCenter (Part of the AppSupport.framework on iOS), which gives you the posibility to process a reply asynchronously in a block.
#import "BEDistributedMessagingCenter.h"
//...
BEDistributedMessagingCenter* center = [BEDistributedMessagingCenter centerNamed:@"aCenterName"];
rocketbootstrap_distributedmessagingcenter_apply(center); //iOS 7+ only
//...
[center sendMessageAndReceiveReplyName:@"aMessageName" userInfo:@{@"someKey": someData} toCallbackBlock:^(id answer) {
//do something with answer;
}];
To use in your own project make sure you link to the library available in Cydia. Update your (Theos) makefile: include libbedistributedmessagingcenter and rocketbootstrap (iOS 7+).
Also make sure ARC is on.
TARGET := iphone:clang
[...]
ADDITIONAL_OBJCFLAGS = -fobjc-arc
[...]
yourProjectName_LIBRARIES = [...] rocketbootstrap libbedistributedmessagingcenter
@joedj - for rewriting the block caching
@rpetrich - for pointing out memory leaks (unretainable blocks) and for the very streamlined version
@uroboro - for good tips
@DHowett - for clarification on ARC and blocks