sebikeller / BEDistributedMessagingCenter

CPDistributedMessagingCenter enhanced with Blocks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BEDistributedMessagingCenter

(BlocksEnhancedCPDistributedMessagingCenter)

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.

Usage:

#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

Special Thanks

@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

About

CPDistributedMessagingCenter enhanced with Blocks

License:MIT License


Languages

Language:Objective-C 100.0%