Last active
          August 29, 2015 14:15 
        
      - 
      
- 
        Save aqubi/d2c85e99cbbfba2d69c8 to your computer and use it in GitHub Desktop. 
    DarwinNotifyCenter
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | - (void)addObserver { | |
| CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), | |
| NULL, | |
| MyCallBack, | |
| CFSTR("MyNotificationName"), | |
| NULL, | |
| CFNotificationSuspensionBehaviorDeliverImmediately); | |
| } | |
| static void MyCallBack(CFNotificationCenterRef center, void *observer, CFStringRef name,const void *object, CFDictionaryRef userInfo) { | |
| NSLog(@"observer: %@", observer); | |
| NSLog(@"name: %@", name); | |
| NSLog(@"userinfo: %@", userInfo); | |
| NSLog(@"object: %@", object); | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | - (void)postNotification { | |
| CFNotificationCenterRef notification = CFNotificationCenterGetDarwinNotifyCenter(); | |
| CFNotificationCenterPostNotification(notification, CFSTR("MyNotificationName"), NULL, NULL, YES); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment