IOS 通知模式
发布日期:2021-11-21 04:41:02 浏览次数:43 分类:技术文章

本文共 850 字,大约阅读时间需要 2 分钟。

-(void)handleTerminate:(NSNotification*)notification{    NSDictionary *theData = [notification userInfo];        if (theData != nil) {        NSDate *date = [theData objectForKey:@"TerminateDate"];        NSLog(@"MainViewController App Terminate Date: %@", date);    }}

处理监听到通知处理

[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(handleTerminate:) name:@"AppWillTerminateNotification---" object:nil];
进行监听

NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:                          @"helloword",@"TerminateDate",                         nil];                                                      [[NSNotificationCenter defaultCenter]postNotificationName:@"AppWillTerminateNotification---" object:nil userInfo:dic];

发送通知

2014-03-26 16:37:45.643 州22[5506:60b] MainViewController App Terminate Date: helloword
处理结果---

转载地址:https://blog.csdn.net/xiaoji94shen/article/details/22191061 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:IOS---在documents中创建可以编辑的plist文件
下一篇:IOS---通过控件实现界面跳转

发表评论

最新留言

初次前来,多多关照!
[***.217.46.12]2024年04月16日 21时35分04秒