title: How to implement a NSNotificationCenter (block style)?
body: <p>It's an interview question. I know how to implement a non-block Notification Center with NSDictionary. But I have no idea how to implement a block NSNotification center because there is no "observer". Here is the code. Any idea?</p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  
  /** LBNotificationCenter.h */
  
  typedef void (^Observer)(NSString *name, id data);
  
  @interface LBNotificationCenter : NSObject
  
  - (void)addObserverForName:(NSString *)name block:(Observer)block;
  - (void)removeObserverForName:(NSString *)name block:(Observer)block;
  - (void)postNotification:(NSString *)name data:(id)data;
  
  @end
  
  /** LBNotificationCenter.m */
  
  @interface LBNotificationCenter ()
  
  @end
  
  @implementation LBNotificationCenter
  
  - (instancetype)init 
  {
      self = [super init];
      if (self) {
  
      }
      return self;
  }
  
  - (void)addObserverForName:(NSString *)name block:(Observer)block 
  {
        //add your code here
  }
  
  - (void)removeObserverForName:(NSString *)name block:(Observer)block 
  {
         //add your code here
  }
  
  - (void)postNotification:(NSString *)name data:(id)data 
  {
      //add your code here
  }
  </code></pre>