#import <UIKit/UIKit.h>
extern NSString * const BNRColorChangedNotification;@interface NotificationViewController : UIViewController {
}
-(IBAction)changeBackgroundColor:(id)sender;
@end
#import "NotificationViewController.h"
@implementation NotificationViewController
NSString * const BNRColorChangedNotification = @"BNRColorChanged";
-(IBAction)changeBackgroundColor:(id)sender{
[[NSNotificationCenter defaultCenter] postNotificationName:BNRColorChangedNotification object:self]; //把消息发给NSNotificationCenter
}
@end
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(outPutTh) name:BNRColorChangedNotification object:nil];
//在要接受消息的地方注册,当有BNRColorChangedNotification消息发出的时候 执行outPutTh函数