注冊(cè)通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showRegisteSucceed:) name:@"showRegisteSucceed" object:nil];
- (void)showRegisteSucceed:(NSNotification *)noti{
NSString *title = noti.userInfo[@"title"];
NSString *message = noti.userInfo[@"message"];
[self showRegisterSucceedAlertWithTitle:title message:message];
}
發(fā)送通知
NSString *title = @"尊貴的會(huì)員";
NSString *message = [NSString stringWithFormat:@"您的用戶名是%@, 默認(rèn)密碼是%@, 如需更改密碼請(qǐng)移步至設(shè)置頁(yè)面", _strOfUserName, _strOfPwd];
//添加 字典,將label的值通過(guò)key值設(shè)置傳遞
NSDictionary *dict =[[NSDictionary alloc] initWithObjectsAndKeys:title, @"title", message, @"message", nil];
//創(chuàng)建通知
NSNotification *notification =[NSNotification notificationWithName:@"showRegisteSucceed" object:nil userInfo:dict];
//通過(guò)通知中心發(fā)送通知
[[NSNotificationCenter defaultCenter] postNotification:notification];