作者:sanfengflying
NSDistributedNotificationCenter 是個好東西,在mac上可以程序間通訊,可惜iOS不支援,參考
http://stackoverflow.com/questions/14582854/various-types-of-notification-centers-available-for-ios,如果要程序間通訊可以考慮
1.私有架構<code>/System/Library/PrivateFrameworks/AppSupport.framework中的</code><code>CPDistributedMessagingCenter</code>
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
//接收方
- (void)addObserver:(id)observer selector:(SEL)aSelector name:(NSString *)aName object:(NSString *)anObject;
- (void)removeObserver:(id)observer name:(NSString *)aName object:(NSString *)anObject;
重新定以後,就可以和原來一樣用了,因為在ios上這些庫沒有被導出,用class-dump還是能夠看到的。
網絡上志同道合,我們一起學習網絡安全,一起進步,QQ群:694839022