[转载]NSDistributedNotificationCenter

NSDistributedNotificationCenter 是个好东西,在mac上可以进程间通讯,可惜iOS不支持,参考
http://stackoverflow.com/questions/14582854/various-types-of-notification-centers-available-for-ios,如果要进程间通讯可以考虑
1.私有框架/System/Library/PrivateFrameworks/AppSupport.framework中的CPDistributedMessagingCenter

Documentation here: http://iphonedevwiki.net/index.php/CPDistributedMessagingCenter

Example codes of mine here:

https://github.com/H2CO3/PwnTube

https://github.com/H2CO3/Cereal

2. CMessagePort

3. mmap

.......


如果你还不死心,非要用此NSDistributedNotificationCenter,可以,自己定义接口,

 

//发送方

@interface NSDistributedNotificationCenter : NSNotificationCenter

+ (id)defaultCenter;

- (void)postNotificationName:(NSString *)aName object:(NSString *)anObject userInfo:(NSDictionary *)aUserInfo;

@end


//接收方

 

@interface NSDistributedNotificationCenter : NSNotificationCenter

+ (id)defaultCenter;

- (void)addObserver:(id)observer selector:(SEL)aSelector name:(NSString *)aName object:(NSString *)anObject;

- (void)removeObserver:(id)observer name:(NSString *)aName object:(NSString *)anObject;

@end


重新定以后,就可以和原来一样用了,因为在ios上这些库没有被导出,用class-dump还是能够看到的。

原文地址:https://www.cnblogs.com/cnsec/p/11515805.html